注解操作入门
1.在配置文件中开启注解扫描
<context:component-scan base-package="com.it" />
2.先注入对象
在类上加注解 @Component 注意不能加载接口
注册类(只能加载实现类)
@Component 其他类!!!(增强AOP)
@Controller web层
@Service service层
@Repository dao层
注册类中的属性
@Autowired
@Qualifier("名字")
@Resource(name="名字") 相当于@Autowired+@Qualifier("名字") 注意名字的默认值类名把首字母变成小写
@Value("值") 注入普通属性
@Scope("prototype")
注册类中对应方法上
@PostConstruct
@PreDestory