1、声明Bean的注解
@Component:元数据使用
@Repository:数据访问层使用
@Service:业务逻辑层使用
@Controller:控制层使用
2、注入(创建对象)Bean的注解
@Autowired:Spring提供的注解
@Inject:JSR-330提供的注解
@Resource:JSR-250提供的注解
注意:注解在属性名或setter方法效果一致
3、扫描批量注册Bean
@ComponentScan:自动扫描指定包中所有使用@Service、@repository、@Component、@controller注解的类,并注册为Bean。
4、配置注解
@Configuration:配置类
5、返回值对象
@Bean:注解在方法上表示方法返回一个对象