失败:(ID:838926df)没有找到任何带有 Main-Class 清单条目的 jar 文件

问题描述 投票:0回答:5

在我的 spring boot 应用程序上运行

gcloud app deploy
时,此错误发生在 Cloud Build 中。

spring-boot google-cloud-platform gcloud google-cloud-build
5个回答
5
投票

可能有一个或多个问题导致您收到此错误。 对于解决方案,请检查以下内容 -

  1. 你的

    app.yaml
    应该有入口点和运行时信息如下-

    runtime: java11

    entrypoint: java -Xmx64m -jar blahblah.jar

  2. 你的

    pom.xml
    应该有appengine maven插件依赖

`

<plugin>
   <groupId>com.google.cloud.tools</groupId>    
   <artifactId>appengine-maven-plugin</artifactId>
   <version>2.2.0</version>
</plugin>

`

  1. 如果你想替换任何配置使用命令不要修改 jar -

    jar uf blahblah.jar filename.yaml

  2. 确保你有像这样的

    pom.xml
    罐子包装 -
    <packaging>jar</packaging>


3
投票

我的maven插件不小心删了,别删了

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

2
投票

我能够通过添加

为我的 AppEngine + Gradle 项目修复它
jar {
    enabled = false
    archiveClassifier = ''
}

到 build.gradle 文件。


1
投票

尝试在pom.xml中注释掉打包成war文件,例子:

<!--  <packaging>war</packaging> -->

它为我解决了这个问题。好的最小+可行示例在这里:https://codelabs.developers.google.com/codelabs/cloud-app-engine-springboot#0


0
投票

根本原因是打包后的

.jar
文件在
Main-Class
中没有
/META-INF/MANIFEST.MF
入口。

我原来的

MANIFEST.MF
文件是这样的:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.8.6
Built-By: me
Build-Jdk: 19.0.1

对我来说,解决方案是添加

maven-jar-plugin
并手动配置
mainClass

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
            <archive>
                <manifest>
                    <mainClass>my.main.MainClass</mainClass>
                </manifest>
            </archive>
        </configuration>
    </plugin>

这导致了以下

MANIFEST.MF

Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 19
Main-Class: my.main.MainClass

您也可以查看 https://www.baeldung.com/spring-boot-main-class 了解其他选项,但是您必须使用

spring-boot-starter-parent
作为父...

© www.soinside.com 2019 - 2024. All rights reserved.