Basic bean wiring(Chapter 2 of Spring In Action)

  There is no single Spring container. Spring comes with several container implementations that can be categorized into two distinct types. Bean factories (defined by the org.springframework.beans.factory.BeanFactory interface) are the simplest of containers, providing basic support for DI. Application contexts (defined by the org.springframework.context.ApplicationContext interface) build on the notion of a bean factory by providing application framework services, such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners.

  Spring provides four flavors of autowiring:

  ■ byName—Attempts to find a bean in the container whose name (or ID) is the same as the name of the property being wired. If a matching bean is not

found, the property will remain unwired.

  ■ byType—Attempts to find a single bean in the container whose type matches the type of the property being wired. If no matching bean is found,

the property will not be wired. If more than one bean matches, an org.springframework.beans.factory.UnsatisfiedDependencyException will be thrown.

  ■ constructor—Tries to match up one or more beans in the container with the parameters of one of the constructors of the bean being wired. In the

event of ambiguous beans or ambiguous constructors, an org.springframework.beans.factory.UnsatisfiedDependencyException will be thrown.

  ■ autodetect—Attempts to autowire by constructor first and then using byType. Ambiguity is handled the same way as with constructor and byType wiring. 

 

   

转载于:https://www.cnblogs.com/zhtf2014/archive/2010/06/20/1761482.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值