I have a problem with Spring Boot Configurations and Injections. I had the following class:
@Configuration
@ConfigurationProperties("app")
public class AppConfig() {
public void A() { ...};
}
And everything works fine with it. Now I have to split up this class in dependence of the OS and my idea was it, to do this like this:
public interface AppConfig() {
void A();
}
public WindowsAppConfig implements AppConfig() {
public void A() { //Windows implementation};
}
public LinuxAppConfig implements AppConfig() {
public void A() { //Linux implementation };
}
@Configuration
public class AppConfigFactory() {
@Bean
public AppConfig getAppConfig() {
if(...) {
return new WindowsAppConfig;
} else {
return new LinuxAppConfig;
}
}
public class AppStart() {
@Autowired
private AppConfig appConfig;
}
Now I get an IllegalStateException like this:
java.lang.IllegalStateException: No ConfigurationProperties annotation found on 'appconfig.AppConfig'.
How and where I can add the ConfigurationProperties correctly?