1、简介
在Spring3.0升级了纯注解开发模式,使用Java类来代替配置文件,开启了Spring快速开发赛道。
2、定义bean
@Component
@Service
@Controller
@Repository
3、纯注解开发
使用@Configuration声明一个配置类,使用@ComponentScan来扫描作为bean的类。
最后使用AnnotationConfigApplicationContext类来创建容器
在Spring3.0升级了纯注解开发模式,使用Java类来代替配置文件,开启了Spring快速开发赛道。
@Component
@Service
@Controller
@Repository
使用@Configuration声明一个配置类,使用@ComponentScan来扫描作为bean的类。
最后使用AnnotationConfigApplicationContext类来创建容器