1

I have a springconfig.xml file and i used to get the bean property values from my.properties file. property file values are changed dynamically. but it will not set to the spring bean property. it will change only after i restart my tomcat. Here is my part of xml code.

<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>

if i change the my.properties value to "foo" it will work. again i change "foo" to "boo" at runtime it will not work. It will not assign to ${queuename}.

manually i changed my.properties value at runtime. it will not affect springconfig.xml

It is possible to change xml values at runtime? Thanks in advance

Sathish vp
  • 72
  • 12
  • Property file changes will affect in application only after restarting your server. Without doing any code change if you want to change something you need to use property file. Property file is for initial setup. Please understand why property file is. – Prasath Apr 05 '19 at 11:11
  • yeah, i know that. i changed the values dynamically at runtime by using some code. the property file(my.properties) is updated. but it will not affect to the springconfig.xml {queuename}. – Sathish vp Apr 05 '19 at 11:14
  • It will not affect @Sathish. That is why I am telling understand the concept of property file. If you are updating the values dynamically then why you didn't update the values in java bean itself? – Prasath Apr 05 '19 at 11:17
  • Why java to props then props to xml then xml to java. You can directly update the value in java directly. – Prasath Apr 05 '19 at 11:19
  • Again why you are setting it into xml. However from xml you are going use as java object. So u can directly set it in java object. – Prasath Apr 05 '19 at 11:27
  • I called a one restapi, that will give a one result. and im not able to set it to the xml bean property. NOTE: restapi result will change every call. – Sathish vp Apr 05 '19 at 12:34
  • that is my requirement @Prasath – Sathish vp Apr 05 '19 at 12:54
  • If that is your requirement, then you should create new JmsTemplate instance for every rest call and you need to use the instance. Xml configuration is one time configuration. – Prasath Apr 05 '19 at 14:06

2 Answers2

0

You'd need to watch the file programmatically in order to reload the changes or use this bean org.springframework.context.support.ReloadableResourceBundleMessageSource
to reload properties file.

bummi
  • 27,123
  • 14
  • 62
  • 101
-2

Try using SpringBoot or IntelliJ Idea ;)

  • Is that answers to his question? Please post answers if it solves his question or problem. If you are not clear in their questions ask it in comments section. – Prasath Apr 05 '19 at 11:13
  • Please post the code snippet that you think can solve his problem. – Pawan Tiwari Apr 05 '19 at 11:15