I have a maven multi module app with the structure :
-parent_project
-actual_project
-jpaBase
Parent project is a maven aggregation of the projects : actual_project and jpaBase (both spring boot applications)
jpaBase is a dependency of actual_project.
Now when i do a mvn package I am getting a unit test error :
Found multiple @SpringBootConfiguration annotated classes
because both jpaBase and actual_project have classes annotated with @SpringBootConfiguration.
How can I make sure that Spring considers the SpringBootConfiguration class of only actual_project and not of jpaBase.
Thanks!
From the Spring documentation :
Application should only ever include one @SpringBootConfiguration and most idiomatic Spring Boot applications will inherit it from @SpringBootApplication.
You said :
because both jpaBase and actual_project have classes annotated with @SpringBootConfiguration.
It should not. This annotation has to be used a single time by application. So, only actual_project and parent_project which are Spring Boot applications should declare this annotation.
@SpringBootConfiguration
replaces the declaration of these annotations:
@Configuration
, @EnableAutoConfiguration
and @ComponentScan
You have the information in the official documentation.
So, in your jpaBase project, you could replace
@SpringBootConfiguration
by the declaration of these three annotations :
@Configuration
@EnableAutoConfiguration
@ComponentScan({ "yourPackage" })
public class JpaConfig {
....
}