Here's my yaml file, and I want to load my properties depends on activation value.
emp:
activate: a
a:
param1: value1
param2: value2
b:
param1: value1
param2: value2
I want to do if activate value is 'a' then load 'a'.
on my source code, AppConfig
@Getter @Setter
@Configuration
@ConfigurationProperties @RequiredArgsConstructor
public class AppConfig {
@NestedConfigurationProperty
private final EmpConfig empConfig;
}
my EmpConfig
@Configuration
@ConfigurationProperties(prefix = "emp")
public class EmpConfig {
private String activate;
private Emp a;
private Emp b;
public Emp getEmpConfig(){
if(activate.equals("a"))
return a;
return b;
}
@Getter
@Setter
public static class Emp {
private String param1;
private String param2;
}
}
But those code got bean creation error. Is there any nice method to resolve this problem?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…