首页 > 编程语言 > 详细

[Spring] Autowire

时间:2018-06-02 18:07:27      阅读:224      评论:0      收藏:0      [点我收藏+]

1.  Autowire可以让你隐式地注入依赖.(it internally uses setter or constructor injection)

2.优点:减少代码量.

3.缺点:无法被程序员控制. 不能用在基本数据类型和string值.

4. Autowiring Modes模式

1) no It is the default autowiring mode. It means no autowiring bydefault.
2) byName The byName mode injects the object dependency according to name of the bean. In such case, property name and bean name must be same. It internally calls setter method.
3) byType The byType mode injects the object dependency according to type. So property name and bean name can be different. It internally calls setter method.
4) constructor The constructor mode injects the dependency by calling the constructor of the class. It calls the constructor having large number of parameters.
5) autodetect It is deprecated since Spring 3.

byName和byType在另一片随笔中.

[Spring] Autowire

原文:https://www.cnblogs.com/zienzir/p/9126078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!