Is it possible to exclude a class from auto-configuration
based on the value of a property?
In my case I want to disable,
MailSenderAutoConfiguration
in some case.
For example,
say I have this property app.email.disabled=true
in my application.properties
,
I would like something like this:
@SpringBootApplication
@EnableAutoConfiguration(exclude = MailSenderAutoConfiguration.class, ifProperty="app.email.disabled")
public class Application { .... }
I know I can declare a bean of type JavaMailSender
and use @ConditionalOnProperty
,
but I already defined all email's properties in the
application.properties
and
I don't want to repeat them again in a class.