注解自动装配
1导入约束
2配置注解的支持
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
加入配置注解的支持
```<context:annotation-config/>
@Autowired
直接在属性上使用就可以,也可以在set方法上使用。使用Autowired不用编写set方法,但是对应名称,值得在ioc容器中
@Autowired()在环境复杂时 用下面属性来实现指定装配
@Qualifier(value="cat11")//指定唯一bean id