简体   繁体   English

如何在 spring 应用程序中动态修改 application.properties 文件?

[英]How to Modify application.properties file dynamically in spring application?

Currently we have spring applications which are deployed on to Tomcat Servers.We are trying to update application.properties dynamically on the fly, without restarting our server/service.目前我们有 spring 应用程序部署到 Tomcat 服务器上。我们正在尝试动态更新 application.properties,而无需重新启动我们的服务器/服务。 What are our options?我们有哪些选择? Do we need right any polling service which listens to event changes and update props file?我们是否需要任何侦听事件更改和更新道具文件的轮询服务?

You can use the Spring Config project.您可以使用Spring 配置项目。 As per the microservice architecture, you can define a different spring profile based on the environment and you will get the capability to reload application properties on the fly without restarting the application using Spring cloud bus events.根据微服务架构,您可以根据环境定义不同的 spring 配置文件,您将能够使用 Spring 云总线事件即时重新加载应用程序属性,而无需重新启动应用程序。 The same setup can be useful in monolithic architecture as well.同样的设置在单体架构中也很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM