반응형

 

- ReloadConfig

@Component

public class ReloadConfig {

  private ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration> builder;

 

  @Value("${spring.profiles.active}")

  private String active;

 

  @PostConstruct

  void init() {

    builder = new ReloadingFileBasedConfigurationBuilder<>(PropertiesConfiguration.class)

                    .configure(new Parameters().fileBased().setFile(new File("./properties-" + active + ".properties")));

    PeriodicReloadingTrigger periodicReloadingTrigger = new PeriodicReloadingTrigger(

      builder.getReloadingController(), null, 50, TimeUnit.SECONDS

    );

    periodicReloadingTrigger.start();

  }

 

  public Configuration getConfig() {

    try {

 

    } catch(ConfigurationException e) {

      e.printStackTrace();

    }

    return null;

  }

}

 

- properties-local.properties

mail.receivers:aaa@aaa.com,bbb@bbb.com,ccc@ccc.com

 

- 사용

@Autowired

private ReloadConfig reloadConfig;

 

public void sendEmail() {

  String[] mailReceivers = reloadConfig.getConfig().getString("mail.receivers").split(",");

}

 


"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."
반응형
LIST

+ Recent posts