I have a webservice that fetches property from application.properties file located in server like query[testSql] through spring
public class RuntimeEnvironmentPropertiesConfigurerextends PropertyPlaceholderConfigurer
implements InitializingBean, RuntimeEnvironmentInterface
Now that query is injected in my Spring bean dao.
<bean id="dao" name="dao" class="com.dao.DaoImpl">
<property name="ackJdbcTemplate" ref="ackJdbcTemplate" />
<property name="testSql" value="${dao.query.tSql}" />
</bean>
With help from How can I reload properties file in Spring 4 using annotations? link I am able to reload the property at run time. verified by
@Autowired
public RuntimeEnvironmentInterface propertyLoader;
....
Set s=propertyLoader.getProperties();
Iterator itr=s.iterator();
while(itr.hasNext()){
String tempKey=String.valueOf(itr.next());
logger.info(tempKey +"==="+propertyLoader.getProperty(tempKey));
but problem is my dao bean does not take updated testSql query.It runs on old one untill I restart the application.
I found a way like in separate url mapping i wrote a method which does below job:
Dao.setTestSql(propertyLoader.getProperty("com.dao.query.tSql"));
and the person who is updating she have to hit the url after updating the property.
But this I have to do for all the bean and and injected property.That is pretty hectic job.I miss one property and I am doomed. Is there any other way to automatically update the injected bean?I need that my updated properties are reflected without restart .
I tried to understand wuenschenswert code given but was unable to.