@Autowired 使用在字段上 对类进行依赖注入
@Resource 相当于 @Autowired + @Qualifier
@Component 用于类上 实例化bean
@Controller 用于controller层实例化bean
@Service 用于service层 实例化bean
@Repository 用于dao 层 bean实例化
@Value 普通属性注入
@Scope bean 作用范围
@PostConstruct 使用在方法上 bean的初始化方法
@PreDestroy 使用在方法上 bean的销毁方法
延伸注解
@Configuration 指定当前类是一个配置类,容器什么时候创建 什么时候加载该注解
@ComponentScan 用于指定Spring初始化扫描包,和spring.xml文件中的
<context:component-scan/>一样
@PropertySource 用于加载properties配置文件
@Import 导入配置类