It seems that you are trying to use @Validated
for spring beans, using Spring MVC approach.
From this article, looks like you need to declare an additional bean.
@Bean
public static MethodValidationPostProcessor validationPostProcessor() {
return new MethodValidationPostProcessor();
}
Instead of relying on @ConditionalOnProperty
during creation of MyService
you can create a @Conditional
bean which will validate values of the properties.