|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
由于这些智能化家电的市场需求没有预期的高,Sun放弃了该项计划。就在Oak几近失败之时,随着互联网的发展,Sun看到了Oak在计算机网络上的广阔应用前景,于是改造了Oak,
Spring_Autowiringcollaborators
在Spring3.2.2中主动拆卸范例,分离为:no(default)(不接纳主动拆卸)、byName,byType,constructor上面来分离先容一下这些是怎样主动拆卸的
<beanid="foo"class="...Foo"autowire="autowiretype">
ModeExplanation
no:(Default)Noautowiring.Beanreferencesmustbedefinedviaarefelement.
Changingthedefaultsettingisnotrecommendedforlargerdeployments,
becausespecifyingcollaboratorsexplicitlygivesgreatercontrolandclarity.
Tosomeextent,itdocumentsthestructureofasystem.
byName:Autowiringbypropertyname.
Springlooksforabeanwiththesamenameasthepropertythatneedstobeautowired.
Forexample,ifabeandefinitionissettoautowirebyname,
anditcontainsamasterproperty(thatis,ithasasetMaster(..)method),
Springlooksforabeandefinitionnamedmaster,andusesittosettheproperty.
byType:Allowsapropertytobeautowiredifexactlyonebeanofthepropertytypeexistsinthecontainer.
Ifmorethanoneexists,afatalexceptionisthrown,
whichindicatesthatyoumaynotusebyTypeautowiringforthatbean.
Iftherearenomatchingbeans,nothinghappens;thepropertyisnotset.
constructor:AnalogoustobyType,butappliestoconstructorarguments.
Ifthereisnotexactlyonebeanoftheconstructorargumenttypeinthecontainer,afatalerrorisraised
案例剖析:
1、创立CumputerBean类- packagewww.csdn.spring.autowire.bean;
- publicclassCumputerBean{
- //电脑称号
- privateStringname;
- publicvoidsetName(Stringname){
- this.name=name;
- }
- }
复制代码- packagewww.csdn.spring.autowire.bean;
- publicclassCumputerBean{
- //电脑称号
- privateStringname;
- publicvoidsetName(Stringname){
- this.name=name;
- }
- }
复制代码 <p>
Java伴随着互联网的迅猛发展而发展,逐渐成为重要的网络编程语言。Oracle收购Sun后Java前途未卜。 |
|