开发者

Datasource setting saved in properties file not loaded until after reboot

开发者 https://www.devze.com 2023-01-24 18:21 出处:网络
My application source its Datasource settings from a properties file. When I start Tomcat I load the properties file, make changes to it depending on the enviroment Tomcat is running, typically UAT or

My application source its Datasource settings from a properties file. When I start Tomcat I load the properties file, make changes to it depending on the enviroment Tomcat is running, typically UAT or Production - and base on this pass the appropriate Setting values require for Database connection.

My problem is, when the properties开发者_如何学Python file is updated at bootstrap for the first time with the new connection values, on tomcat - Spring sessionFactory do not seem to acquire the current updated values, and therefore end up with Database connection exception. But when I restart Tomcat - sessionFactory now have access to the updated values.

My question is - do anyone know why sessionFactory only works with the previous values as oppose to the updated settings values?


I think the only way is to restart tomcat, because connection creates in spring context. Spring context creates on start up. When you change something in property file, actually it doesn't influence on spring context, because it is already created.


I Used Maven Filter to replace profile properties at build time.

0

精彩评论

暂无评论...
验证码 换一张
取 消