I am trying to set a property value using spring.
<bean id="velocityPropsBean" class="com.test.CustomProperties" abstract="false" singleton="true" lazy-init="false" autowire="default" dependency-check="default">
<property name="properties">
<props>
<prop key="resource.loader">file</prop>
<prop key="file.resource.loader.cache">true</prop>
<prop key="file.resource.loader.class">org.apache.velocity.runtime.resource.loader.FileResourceLoader</prop>
<prop key="file.resource.loader.path">NEED TO INSERT VALUE AT STARTUP</prop>
</props>
</property>
</bean>
<bean id="velocityResourcePath" class="java.lang.String开发者_Go百科" factory-bean="velocityHelper" factory-method="getLoaderPath"/>
Now what i need to do is insert the result from getLoaderPath into file.resource.loader.path. The value of getLoaderPath changes so it has to be loaded at server startup.
Any thoughts how i can inset the velocityResourcePath value to the property?
Using Spring 3, you can skip the middle stage, and invoke the factory directly using SpringEL:
<prop key="file.resource.loader.path">#{ velocityHelper.loaderPath }</prop>
or perhaps
<prop key="file.resource.loader.path">#{ velocityHelper.getLoaderPath() }</prop>
This would let you remove the velocityResourcePath
bean.
Below code might help you.
<import resource="classpath:/DaoContext.xml"/>
<bean id="ClientMasterDao" class="dao.hibernate.impl.ClientMasterImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="ClientMasterServices" class="client.ClientMasterServices">
<property name="clientDao" ref="ClientMasterDao"/>
</bean>
精彩评论