目录
Spring1
3、HelloSpring
4、IOC创建对象方式
4.1 方式一
4.2 方式二
5、Spring配置
5.1 别名
5.2 Bean的配置
5.3 import
Spring2
Spring3
单例模式(面试)
Spring4
使用Java来配置bean
spring官方的文档有这样一段描述,context:component-scan base-package/@ComponentScan will do an auto-scanning. Assuming each class that has to become a bean is annotated with a correct annotation like @Component
(for simple bean) or @Controller
(for a servlet control) or @Repository
(for DAO
classes) and these classes are somewhere under the package, Spring will find all of these and create a bean for each one.
这里@componetScan或context:component-scan base-package会扫描将带有注解@Component的类注册为bean。无关@Configuration和@Bean
pojo类包
1、@Component
config包
1、@Configuration
2、@ComponentScan("com.github.pojo")
3、在方法上添加注解@Bean