classes
参数不是可选的(它通常是使用标准Maven项目结构推断的),但是您可以为其提供一个空目录,然后使用参数folders
包含先前打包的JAR。这里有一个例子
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.this.that.YourApplication</mainClass>
<!-- any directory will do as long as (a) it exists and (b) it does not contain classes -->
<classesDirectory>/tmp/</classesDirectory>
<folders>
<folder>
<!-- the address, relative to the plugin's workingDirectory, of the 'original' application JAR -->
tmp/lib/your-application.jar.original
</folder>
</folders>
</configuration>
</plugin>
有了这个配置,如果你-X
运行,你会看到,前两个项目的类路径中由Spring启动插件催生了JVM是:(1)你的应用程序JAR和(2 )空的类目录。例如:
[DEBUG] Classpath for forked process: <full_path_removed>/tmp/lib/your-application.jar.original:/tmp:
注:
- 你需要,因为你使用的是原来的JAR不包括在META-INF/MANIFEST.MF主类指令提供
mainClass
- 您需要引用“原始”JAR而不是Spring Boot打包的JAR,因为原始JAR是包含应用程序的主类在其原始位置(Spring Boot打包的JAR重定位它)的JAR。