Динамическое изменение содержимого файла в приложении Java без перезапуска ⇐ JAVA
-
Anonymous
Динамическое изменение содержимого файла в приложении Java без перезапуска
I'm currently developing a Java application where I need to dynamically update the contents of a configuration file (env.properties) while the application is running. The configuration file contains crucial values like db.url and db.token, which are necessary for a database select API. However, since the application is packaged as a .jar file, restarting it every time to provide updated values isn't practical.
I've implemented the code to modify the env.properties file dynamically. However, despite successfully updating the file contents, the application doesn't recognize these changes until it's restarted.
Is there a way to ensure that my Java application dynamically detects and applies changes made to env.properties without requiring a restart?
Or do I need to change the database select API itself.
I tried using a env.properties file outside the repository but It can't be accessed to make the changes.
Источник: https://stackoverflow.com/questions/780 ... ut-restart
I'm currently developing a Java application where I need to dynamically update the contents of a configuration file (env.properties) while the application is running. The configuration file contains crucial values like db.url and db.token, which are necessary for a database select API. However, since the application is packaged as a .jar file, restarting it every time to provide updated values isn't practical.
I've implemented the code to modify the env.properties file dynamically. However, despite successfully updating the file contents, the application doesn't recognize these changes until it's restarted.
Is there a way to ensure that my Java application dynamically detects and applies changes made to env.properties without requiring a restart?
Or do I need to change the database select API itself.
I tried using a env.properties file outside the repository but It can't be accessed to make the changes.
Источник: https://stackoverflow.com/questions/780 ... ut-restart
Мобильная версия