【发布时间】:2017-08-24 19:19:23
【问题描述】:
是否可以直接针对由于包目标而不是源而创建的 jar 文件运行 maven,特别是 spring-boot:run 目标?
我想这样做的原因是因为我想使用 spring boot Devtools(可悲的是如果您使用 Java -jar 运行应用程序,则不起作用)并且我也不想将应用程序的源代码放入容器中。
【问题讨论】:
标签: java maven spring-boot
是否可以直接针对由于包目标而不是源而创建的 jar 文件运行 maven,特别是 spring-boot:run 目标?
我想这样做的原因是因为我想使用 spring boot Devtools(可悲的是如果您使用 Java -jar 运行应用程序,则不起作用)并且我也不想将应用程序的源代码放入容器中。
【问题讨论】:
标签: java maven spring-boot
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 Boot 插件生成的 JVM 的类路径中的前两个条目是 (1) 您的应用程序 JAR 和 (2) 空类目录.例如:
[DEBUG] Classpath for forked process: <full_path_removed>/tmp/lib/your-application.jar.original:/tmp:
注意事项:
mainClass,因为您使用的原始 JAR 不包括 META-INF/MANIFEST.MF 中的 Main-Class 指令【讨论】: