簡體   English   中英

Spring重新加載屬性,而無需重新啟動TOMCAT

[英]Spring reload properties without restarting TOMCAT

我有這個Spring MVC應用程序,它使用PropertyPlaceholderConfigurer來使用@Value注釋加載屬性。 我了解初始化上下文時會在服務器啟動時加載所有屬性。 但是,有沒有一種方法可以訪問更新的屬性而不必重新啟動TOMCAT? (也許利用Apache Commons PropertiesConfiguration)?

有沒有一種方法可以配置Apache Commons PropertiesConfiguration與Spring PropertyPlaceholderconfigurer一起使用?

在使用屬性的類上方添加@RefreshScope注釋(即具有@Value注釋)。 示例如下:

@RefreshScope
class PropertiesConsumer {
  ....
  @Value(..)
  private consumerFoo;
  ....
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM