CT Configuration - prasadtalasila/BITS-Darshini GitHub Wiki
Spring Configuration
@Configuration
This annotation is used on classes that define beans. @Configuration is an analog for an XML configuration file – it is configuration using Java classes. A Java class annotated with @Configuration is a configuration by itself and will have methods to instantiate and configure the dependencies. Example :
@Configuration
public class HelloWorldConfig {
@Bean
public HelloWorld helloWorld(){
return new HelloWorld();
}
}
Examples of Configuration
class in Darshini are given below :
[Notice how beans - ElasticSearchConfig and esFactoryImpl - are defined inside the class, and then are used as autowire elasticSearchConfig field in ElasticSearchConfigTest.java.
Also, notice that there are two bean definitions (ElasticSearchConfig and esFactoryImpl) inside ElasticSearchConfigTestConfig.java, but only one autowired field (elasticSearchConfig) in ElasticSearchConfigTest.java. The other definition (esFactoryImpl) is needed because it is a dependency of ElasticSearchConfig.java in form of an autowired field.]
References
- Using nested imports of configuration - boraji, Tobias Flohre