Skip to content

Instantly share code, notes, and snippets.

View ahwinemman's full-sized avatar
🏠
Working from home

Ahwin Oghenerukevwe ahwinemman

🏠
Working from home
View GitHub Profile
@ahwinemman
ahwinemman / persistence.xml
Created April 22, 2020 02:32 — forked from mortezaadi/persistence.xml
persistence xml configurations for major databases and jpa providers
<?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 June 1, 2020 03:40
In a spring boot application this is the main entrypoint
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 June 1, 2020 03:43
This class is initiated at the start of the application and the values of the properties injected are logged in the terminal
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 June 1, 2020 03:45
This annotation allows us inject string properties
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;
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;
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;
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;
base_url=https://www.github.com/ahwinemman
username=admin
password=admin
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