[英]How to change spring bean property value in xml at runtime?
我有一个springconfig.xml文件,我以前是从my.properties文件中获取bean属性值的。 属性文件的值是动态更改的。 但不会将其设置为spring bean属性。 仅当我重新启动tomcat后,它才会更改。 这是我的xml代码部分。
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:/SATHISH/apache.8.0.24/bin/my.properties</value>
</property>
</bean>
<bean id="jmsEmailTemplateBean" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="authenticationConnectionFactory" />
<property name="defaultDestination" ref="${queuename}" />
</bean>
如果我将my.properties值更改为“ foo”,它将起作用。 我再次在运行时将“ foo”更改为“ boo”,它将无法正常工作。 它不会分配给$ {queuename}。
我在运行时手动更改了my.properties值。 它不会影响springconfig.xml
是否可以在运行时更改xml值? 提前致谢
您需要以编程方式查看文件,以便重新加载更改或使用此bean org.springframework.context.support.ReloadableResourceBundleMessageSource
重新加载属性文件。
尝试使用SpringBoot或IntelliJ Idea;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.