I'm working on a data access library and would like to be able to include it as a dependency in other projects with minimal configuration (ideally just autowire a repo). In particular, this library sets itself up using an autoconfiguration class (enabled in spring.factories
) and needs to disable other autoconfiguration classes to work (DataSourceAutoConfiguration
and HibernateJpaAutoConfiguration
).
Is it possible to do this outside of the dependent project?
To make configuration as simple as possible I'd like to avoid putting excludes in the dependent project's @SpringBootApplication
annotation or its spring.autoconfigure.exclude
property.
Update:
On my @Configuration I have tried adding the annotations:
@EnableAutoConfiguration(exclude={
DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
this causes
IllegalStateException: Configuration problem: A circular @Import has been detected
and
@ImportAutoConfiguration(exclude={
DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
Which simply does nothing.