application context
1.AnnotationConfigApplicationContext
2.AnnotationConfigWebApplicationContext
3.ClassPathXmlApplicationContext
4.FileSystemXmlApplicationContext
5.XmlWebApplicationContext
Wiring beans
1.Explicit configuration in XML
2.Explicit configuration in Java
3.Implicit bean discovery and automatic wiring
Automatically wiring beans [Implicit]
1.Component scanning---Spring automatically disvocers beans to be created in application context
2.Autowiring ---Spring automatically satisfies beans bean dependencies
Component scanning
1.discoverable beans ------@Component ....
2.Scanning -----@ComponentScan. Default Scanning that(which class have @ComponentScan)package and any subpackage.
explicit way -> basePackages={packageName,..} or basePackageClasses={xx.class,yy.class}
Annotating beans to be automatically wired
Autowiring is a means of letting Spring automatically satisfy a bean's dependencies by finding other beans in application context are a match to the bean's needs.
@Autowired --- you can use in a constructor,a setter method,or any other method,Spring will attempt to satisfy the dependency expressed in the method's parameters.
In java and In Xml [explicit]
Importing and mixing configurations
In java
1.@Import("xxx.class")
2.@ImportResource("classpath:xxx.xml")
In Xml
1.<Import resource="xxx.xml" >
2.<Import class="xxxx.config" >
网友评论