java - Spring @PropertySource 刷新

标签 java spring spring-mvc

如何在 spring 中刷新 @PropertySouce(propertyFile)。

例如:- 属性文件中有一个参数:-

   MY_APP_NAME=MY APPLICATION

我正在使用

   @Autowired Enviornment env;

从属性文件中获取属性值。

之后,我想将属性从“我的应用程序”更改为“应用程序”。

    MY_APP_NAME=APPLICATION

它需要重新启动应用程序,但我不想重新启动应用程序。我希望当我更改属性时,它会在几秒钟后反射(reflect)在应用程序中。

最佳答案

如果你的项目是springboot你可以使用actuator,你可以使用'http://localhost:port/refresh ' 刷新您的属性

关于java - Spring @PropertySource 刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51394419/

相关文章:

java - Spring Webflow - 无法在模型 bean 上调用注释验证

java - Spring 启动 : How to add interceptors to static resources?

java - 使用 Spring MVC 成功登录后仍然可以返回登录页面

java - 如何调度JSP页面?

java - Node.getTextContent() 在 Node 中未定义

java - Java 中的泛型和泛型哪个更好?

Java - 无法将 lambda 用于自制接口(interface) - lambda 转换的目标类型必须是接口(interface)

java - 如何使用 Selenium WebDriver 打开多个窗口

javascript - 我无法从数组中获取环境名称

spring-mvc - Spring MVC Portlet Eclipse 插件