Pom的spring-boot-maven-plugin中的exec分类器-pod启动错误-Openshift

问题描述

我正试图将微服务推向联系,同时部署到openshift。

我的pom得到了:

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

这将导致在构建时创建两个jar文件。

my-service-exec.jar my-service.jar

我接受了https://docs.spring.io/spring-boot/docs/1.4.1.RELEASE/maven-plugin/examples/repackage-classifier.html的建议,并将exec分类器添加到了pom中。

在部署之后和Pod启动时,我看到以下错误消息:

ERROR Neither $JAVA_MAIN_CLASS nor $JAVA_APP_JAR is set and 2 JARs found in /deployments (1 expected)

并且吊舱没有启动。

在这方面的任何帮助都将受到赞赏。

解决方法

默认情况下,重新打包目标将用重新打包的工件替换原始工件。对于代表应用的模块来说,这是一种理智的行为,但如果您的模块用作另一个模块的依赖项,则需要为重新打包的模块提供分类器。

这样做的原因是应用程序类打包在 BOOT-INF/classes 中,因此依赖模块无法加载重新打包的 jar 类。 spring docs

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...