##注解说明
@Autowired 自动装配先通过类型再通过名字。如果AUTOWIRED不能唯一自动装配上属性,则需要通过@Qualifier(valuer=“xxx”)
需要添加context配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<!--开启注解支持-->
<context:annotation-config/>
<beans/>
@Resource 自动装配先通过名字在通过类型。
@Component:组件,放在类上,说明这个被SPRING管理了,就是BEAN
@Value 属性值注入
@Scope 作用域注解
##衍生的注解
@Component有几个衍生注解,在web开发中,按照MVC三层架构分层!
1.dao [@Repository]
2.service [@Service]
3.controller [@Controller]
这四个注解功能都是一样的,都是将某个类注册到Spring中,装备Bean