1.介绍
1.1 目标
通过本系列文章能够熟悉并掌握Spring注解驱动开发。本小结将介绍通过注解给容器中注册组件;通过本小结,将了解如下注解:
- AnnotationConfigApplicationContext
组件添加
- @ComponentScan
- @Bean
- @PostConstruct
- @PreDestroy
- BeanPostProcessor
- @Configuration
- @Component
- @Service
- @Controller
- @Repository
- @Conditional
- @Primary
- @Lazy
@Scope
@Import
- ImportSelector
- FactoryBean
1.2 环境信息
环境信息如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.20.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>