首页  :: 新随笔  :: 管理

Spring中的autowire属性(注入)

Posted on 2011-08-01 23:49  季枫  阅读(852)  评论(0)    收藏  举报
使用autowire属性可以实现自动注入,可以取值:byName和byType。
简单示例代码:
<bean id="registerAction" class="com.lantsky.action.RegisterAction" scope="prototype">
  
<property name="userManageService">
    
<ref bean="userManageService"/>
  
</property>
</bean>


可以写成:

 

<bean id="registerAction" class="com.lantsky.action.RegisterAction" scope="prototype" autowire="byName"/>


 

智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |