I have a maven project with the following structure
- Root pom.xml
- module1
- module2
module2 is an integration test module using Spring Boot annotations -
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Config.class, webEnvironment = RANDOM_PORT)
module2 has a dependancy on module1, when the project is built using the spring-boot-maven-plugin it is repackaged and module2 cannot find packages in module1; This can be solved using the classifier as follows
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
The problem now is that when running module2 integration tests the main class can no longer be found, I am guessing this is because module2 is now using the original artifact and not the repackaged one.
Execution default of goal org.springframework.boot:spring-boot-maven-plugin4.6.18.RELEASE:repackag e failed: Unable to find main class
How can this be solved and what is best practice to project strucure when it comes spring boot and integration tests?