The key is to add a class javaConfig @Configuration comment.
@Configuration annotation indicates that this class is a class configuration. Components can initiate a scan for the entity with @Bean instantiate the like bean
@Configuration understood as a spring when the inside xml <beans> tag, which is: disposed spring containers (application context)
@Bean understood as a spring when the inside xml <bean> tag
@ComponentScan(value="com.xxx",excluddFilters={@Filter(type=FilterType.ANNOTATION,classes={Controller.class,Service.class})})
@ComponentScan(value="com.xxx",includeFilters={@Filter(type=FilterType.ANNOTATION,classes={Controller.class},userDefaultFilters=false)})
// value: scan the specified package
// excluddFilters = the Filter [] Specifies exclude those components
// includeFilters = the Filter [] // Specify those containing components to scan, scan only if the configuration includes rules, the same time to configure userDefault-filters = false; disable the default filtering rules;
Filter Type:
@Configuration // == configuration class configuration file, the comment was repeated notes, you can live a comment
@ComponentScan // Enable component scans
public class CDPlayerConfig{
CdPlayer @Bean // instantiate an object placed in the vessel. Registered a bean, id defaults to the method name
public CDPlayer cdPlayer(){
return new CDPlayer();
}
}
Note : @Configuration annotation configuration class has the following requirements:
- @Configuration may not be the final type;
- @Configuration is not anonymous class;
- Nested configuration must be static class.