Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ahwin Oghenerukevwe ahwinemman

🏠
Working from home
View GitHub Profile
@ahwinemman
ahwinemman / persistence.xml
Created Apr 22, 2020 — forked from mortezaadi/persistence.xml
persistence xml configurations for major databases and jpa providers
View persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<!-- derby -->
@ahwinemman
ahwinemman / InjectApplication.java
Last active Jun 1, 2020
In a spring boot application this is the main entrypoint
View InjectApplication.java
package com.spring.injectprops;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class InjectApplication {
public static void main(String[] args) {
SpringApplication.run(InjectApplication.class, args);
@ahwinemman
ahwinemman / MainClass.java
Created Jun 1, 2020
This class is initiated at the start of the application and the values of the properties injected are logged in the terminal
View MainClass.java
package com.spring.injectprops;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.logging.Logger;
@Component
public class MainClass implements CommandLineRunner {
@ahwinemman
ahwinemman / StringProperty.java
Created Jun 1, 2020
This annotation allows us inject string properties
View StringProperty.java
package com.javaee.injectprops.annotations;
import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
View PropertyProvider.java
package com.javaee.injectprops.configuration;
import com.javaee.injectprops.annotations.IntegerProperty;
import com.javaee.injectprops.annotations.StringProperty;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
View ConfigurationManager.java
package com.javaee.injectprops.configuration;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
View MainClass.java
package com.javaee.injectprops;
import com.javaee.injectprops.annotations.StringProperty;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import java.util.logging.Logger;
View application.properties
base_url=https://www.github.com/ahwinemman
username=admin
password=admin
View editorconfig ij specific
root = true
[*]
# charset = utf-8
# end_of_line = lf
# indent_size = 4
# indent_style = space
# insert_final_newline = false
# max_line_length = 120
# tab_width = 4