Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can spring container XML config reference use another bean'property

Here I am writing a spring application, here I want to do is like this:

   <bean id="sqlClient"  class="com.braoda.dao.sqclient.SqlclientWapper">
    <property name="dataSource" ref="dataSource"/>
  </bean>

<bean id="userDao" class="com.braoda.dao.user.UserDaoImpl">
  <property name="sqlSession" ref="***sqlClient.SqlSessionFactoryBean***" />

As the code like, I want use the spring Xml property config from "ref", but "ref" is not a bean but a bean's property. is this illegal in spring or we can not use spring like this.

like image 572
Winston Avatar asked Feb 15 '26 09:02

Winston


1 Answers

Yes, it is possible.

have a look at http://forum.spring.io/forum/spring-projects/container/35869-reference-bean-property-within-reference

which shows code like <property name="username" value="${local.username}"/>

like image 80
Scary Wombat Avatar answered Feb 17 '26 21:02

Scary Wombat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!