Spring-boot-maven-plugin> = 1.4.0 jar structure changes

I have a spring-boot project where all integration tests are in a separate module that launches the application module using spring-boot-maven-plugin during the integration-test phase and runs the package against it. This construct worked fine until it was upgraded to 1.4.0.RELEASE. Now I get a ClassNotFoundException .

After I checked the structure "1.4.0", I realized that its difference from "1.3.6" is one and all the packages are no longer at the top level, but in the BOOT-INF and other folders (see screenshots below) , and the classloader can no longer find the package defined in "mainClass".

Does anyone have any ideas for fixing it and if this solution is possible in the new version?

Thanks in advance!

jar structure <1.4.0

jar structure> = 1.4.0

ITest module:

 <!-- dependency to the app module --> <dependency> <groupId>com.company.app</groupId> <artifactId>app-module</artifactId> <version>1.0.0-SNAPSHOT</version> </dependency> ... <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring.boot.version}</version> <configuration> <mainClass>com.company.app.RunServer</mainClass> </configuration> <executions> <execution> <id>pre-integration-test</id> <goals> <goal>start</goal> </goals> </execution> <execution> <id>post-integration-test</id> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> 

Application module:

 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> 
+2
source share
3 answers

The decision on how to use the Spring boot application as a dependency can be found here .

Essentially, in your maven assembly, add the following:

 <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>exec</classifier> </configuration> </plugin> </plugins> </build> 

This will cause your main jar artifact (the one that will be built in the standard maven assembly) to be structured normally, so you can depend on it, and spring-boot-maven-plugin will repack the jar into a second artifact, this one executable file, with the classifier exec .

+2
source

Hm, there have been a lot of changes in testing recently, so have you checked the update notes for 1.4.0 ?

0
source

There is good documentation for changing class and package names https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.4-Release-Notes

0
source

Source: https://habr.com/ru/post/1011788/


All Articles