spring学习

来源:互联网 发布:苹果mac卸载软件 编辑:程序博客网 时间:2024/06/07 01:53

一:spring setter注入
这里写图片描述
spring加载配置文件时会调用
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
set方法将customerService 注入

换成注解注解方式@Autowired就可以移除<property name="customerService" ref="customerService"></property>
变为
这里写图片描述

二: 注解 <context:annotation-config/><context:component-scan/>
1:
这里写图片描述

2:
这里写图片描述

原创粉丝点击