Spring JavaConfig for Annotation-based Spring Configuration
- Demonstration of JavaConfig Annotation based Spring Configuration
- Beans created in src/main/java/com/gordondickens/javaconfig/AppContext.java
- Tests are in src/test/java/com/gordondickens/javaconfig/AppContextText.java
- Logback with SLF4J for logging, see src/test/resources/logback-test.xml for logging configuration
- @Configuration classes must be non-final
- @Configuration classes must be non-local (may not be declared within a method)
- @Configuration classes must have a default/no-arg constructor
- Cannot use @Autowired constructor parameters
- Nested configuration classes must be static
- Demonstrates using @ComponentScan in place of XML based <context:component-scan/>
- Demonstrates using _@EnableTransactionManagement in place of XML based <tx:annotation-config/>
- Demonstrates using @ImportResource to import XML configuration similar to XML based <import/>
- Demonstrates using @Import in place to import another JavaConfig class similar to XML based <import/>
- Demonstrates using @PropertySource to import properties similar to XML based <context:property-placeholder/>
- Demonstrates using SpEL (Spring Expression Language) and @Value to inject a dependency into an @Bean via an argument
- Demonstrates Nested @Configuration within an existing @Configuration class
- NOTE: Nested @Configuration classes MUST be static
- Demonstrates using an Application Initializer to evaluate an environment parameter at runtime and choosing beans based on that descriminator
- Demonstrates using the @Profile annotation for configuration classes
- Demonstrates using the @ActiveProfiles test annotation for JUnit tests
- Demonstrates how to set the profile and reload the context in the class com.gordondickens.javaconfig.Main.java class
- The Main class can be executed from the command line with mvn exec:java
- TODO - To be implemented