BoundLess

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1.在昨天的基础上再添加一个spring-aop包

2.引入context约束,方法与昨天相同

3.开启使用注解代理配置文件

在xml文件写入如下内容

<context:component-scan base-package="com_spring_bean"></context:component-scan>

4.将对象注册到容器

@Component("user")

@Service("user")  //service层

@Controller("user") //web层

@Repository("user") //dao层

上面四种注解功能相同   推荐使用下面三种    分类清晰

作用等于 <bean name="user" class="com_spring_bean.User"> </bean>

5.修改对象的作用范围

@Scope(scopeName="singleton|prototype") //singleton单例

6.值类型注入

7.导入spring-test

8.测试

 

posted on 2019-05-07 22:19  BoundLess  阅读(84)  评论(0)    收藏  举报