Próbowałem jak poniżej;
public class MySwitch extends AllNestedConditions {
public MySwitch(ConfigurationPhase configurationPhase) {
super(configurationPhase);
}
@ConditionalOnProperty(name = "EnableSomething")
static class OnProperty {
}
}
ale pojawia się błąd taki jak:
Failed to Instantiate as no default Constructor Found
.
Jaki jest prawidłowy sposób to zrobić?
Odpowiedzi:
2 dla odpowiedzi № 1Musisz użyć superkonstruktora, aby powiedzieć sprężynie, w której fazie należy wziąć pod uwagę stan. W twoim przypadku powinno to wyglądać tak:
public class MySwitch extends AllNestedConditions {
public MySwitch() {
super(ConfigurationPhase.REGISTER_BEAN);
}
@ConditionalOnProperty(name = "EnableSomething")
static class OnProperty {
}
}