title: What is the best way to store and change global app properties in Spring Boot in a thread safe way
body: <p>I am using Spring Boot, and loading/generating application properties in @Configuration bean on startup of my app, and placing them in HashMap, for example:</p>
  <pre><code>@Configuration
  public class Config {
  
    @Bean(name = &quot;appConfig&quot;)
    public Map&lt;String, String&gt; getApplicationConfig() {
  
      Map&lt;String, String&gt; appConfig = new HashMap&lt;&gt;();
  
      //load or generate global config varibles
      appConfig.put(&quot;GLOBAL_CONFIG&quot;, &quot;VALUE 1&quot;);
      return appConfig;
  }
  </code></pre>
  <p>I am injecting this map of properties in several beans, for example:</p>
  <pre><code>@RestController
  @RequestMapping(&quot;/getglobalconfig&quot;)
  public class ConfigController {
  
    @Value(&quot;#{appConfig}&quot;)
    private Map&lt;String, String&gt; appConfig;
  
    @GetMapping
    public String getGlobalConfig() { return appConfig.get(&quot;GLOBAL_CONFIG&quot;); }
  }
  </code></pre>
  <p>After some event I want to change for example the value of my appConfig HashMap GLOBAL_CONFIG value in a thread safe way, so that it's updated in all injected beans, like for example in the ConfigController example above.</p>
  <p>What would be the best pattern to accomplish this in a thread safe way and have my beans reloaded value without re-initializing them or restarting the app. Spring cloud config looks interesting, but it's unfortunately unavailable for me.</p>
  <p>I am not limited to HashMap properties, I just need a thread safe reloading of global property so that it's visible in injected beans after reload.</p>