2
public static void main(String[] args) throws InterruptedException {
    DynamicStringProperty property = DynamicPropertyFactory.getInstance().getStringProperty("prop", "test");
    while (true) {
        System.out.println(property.get());
        Thread.sleep(2000);
    }
}

This is my code in a very simple test file. When I manually change the property in the associated config.properties file, the changes do not reflect at runtime. Please advise if I am doing anything wrong?

Sophia Tao
  • 27
  • 3

1 Answers1

0

Call the following function before using the Dynamic Property Factory:

private static void Configure(){

      String url = null;
      try {
         url = new File("src/test/resources/config.properties").toURI().toURL().toString();
      } catch (MalformedURLException e) {
         e.printStackTrace();
      }
      DynamicURLConfiguration dynamicURLConfiguration = new DynamicURLConfiguration(1, 50, false,
              url);
      ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
      finalConfig.addConfiguration(dynamicURLConfiguration, "fileConfig");
      ConfigurationManager.install(finalConfig);
   }
Triyugi Narayan Mani
  • 3,039
  • 8
  • 36
  • 56
Dtwizee
  • 1
  • 1