When using spring-boot-maven-plugin to package JAR for current projects, it is often necessary to add some resources and class files under non-default paths to the JAR package. The following can be configured in pom.xml
<build>
<plugins><plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
<configuration>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>com.test.TestApplication</mainClass>
<layout>ZIP</layout>
<!-- <classesDirectory>target/test-classes</classesDirectory>-->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>target/test-classes</directory>
<includes>
<include>**/*.class</include>
</includes>
</resource>
</resources>
</build>
In this example, class files under target/test-classes are added to the final JAR package as well. In addition, <classes Directory> included in <configuration> is also used in the document to add resources and class files to JAR, but after trying, it doesn't work and I don't know if there is a misconfiguration.
Reference document
Available Plugins
Introduction to Plugin Prefix Resolution
Apache Maven Resources Plugin
Apache Maven Compiler Plugin
Spring Boot Maven Plugin