我在这里写一个spring应用程序,这里我想做的是这样的:
<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***" />就像代码一样,我想从“ref”使用spring Xml属性config,但是“ref”不是bean而是bean的属性。 这在春天是非法的,或者我们不能像这样使用春天。
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.
最满意答案
对的,这是可能的。
看看http://forum.spring.io/forum/spring-projects/container/35869-reference-bean-property-within-reference
它显示的代码如<property name="username" value="${local.username}"/>
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}"/>
更多推荐
发布评论