【问题标题】:exec classifier in spring-boot-maven-plugin in pom - pod startup error - Openshiftpom中spring-boot-maven-plugin中的exec分类器-pod启动错误-Openshift
【发布时间】:2020-12-27 05:19:26
【问题描述】:

我正在尝试将我的微服务推送到 nexus,同时部署到 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 我的服务.jar

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

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

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

并且 pod 没有启动。

非常感谢这方面的任何帮助。

【问题讨论】:

    标签: java openshift maven-2 redhat kubernetes-helm


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-01-27
      • 2014-04-23
      • 2018-12-25
      • 2017-08-02
      • 2018-08-31
      • 2015-08-01
      • 1970-01-01
      • 2022-01-16
      • 2016-09-17
      相关资源
      最近更新 更多