Динамическое изменение содержимого файла в приложении Java без перезапускаJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Динамическое изменение содержимого файла в приложении Java без перезапуска

Сообщение Anonymous »


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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»