【问题标题】:greater than maximum allowed size of [33554432] in Google cloud platform大于 Google 云平台中 [33554432] 的最大允许大小
【发布时间】:2018-12-08 14:17:27
【问题描述】:

在GCP上部署spring-boot app时,出现如下错误。

错误:(gcloud.app.deploy)无法上传文件 [/home/info/Project1/target/appengine-staging/myproject-0.0.1-SNAPSHOT.jar], 其大小为 [42865605](大于最大允许大小 [33554432])。请删除该文件或添加到中的 skip_files 条目 您的应用程序 .yaml 文件,然后重试。

pom.xml如下:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>myproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>myproject</name>
    <description>aaaaaa</description>


    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>    

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <jjwt.version>0.9.0</jjwt.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
            <version>3.2.5</version>
        </dependency>

        <dependency>
          <groupId>com.google.cloud.sql</groupId>
          <artifactId>mysql-socket-factory</artifactId>
          <version>1.0.9</version>
        </dependency>

        <!-- For Working with Json Web Tokens (JWT) -->
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>${jjwt.version}</version>
        </dependency>

        <!-- For Java 8 Date/Time Support -->
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>


    </dependencies>

    <build>
        <plugins>
        <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <version>3.0.0</version>
              <configuration>
                <webResources>
                  <!-- in order to interpolate version from pom into appengine-web.xml -->
                  <resource>
                    <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                    <filtering>true</filtering>
                    <targetPath>WEB-INF</targetPath>
                  </resource>
                </webResources>
              </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                  <executions>
                    <execution>
                      <goals>
                        <goal>repackage</goal>
                      </goals>
                    </execution>
                  </executions>
            </plugin>
        <!-- add appengine-maven-plugin -->
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <deploy.promote>true</deploy.promote>
                    <deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
                </configuration>
            </plugin>
        </plugins>

    </build>

</project>

我已经删除了静态文件,但仍然没有减少 jar 文件。 有人请告诉我如何减小 jar 文件的大小吗?

【问题讨论】:

标签: maven google-app-engine google-cloud-platform


【解决方案1】:

Google App Engine 的部署中每个文件的配额限制为 32 MB(GO 64 MB)。

由于您使用的是 Java,因此您的 SNAPSHOT.jar(40.8 MB)超过了 32 MB 的限制。

此限制适用于标准环境和弹性环境。

App Engine Quotas

【讨论】:

  • 如何获得 64MB?我在 Appengine 中找不到这样的配置。
  • 配额页面列出了支持 64 MB 的 Go 应用程序。但是,文档中其他任何地方的限制都是 32 MB。对于 Java,您的大小限制为 32 MB。要么减小 jar 的大小,要么改用 Compute Engine。
  • 当你说How do I go for 64MB?。我指的是语言GO
  • 由于应用是spring-boot,我无法使用GO。您能否推荐任何其他适合我要求的引擎(jar 大小>42GB)?
  • 我做到了,`Compute Engine`。 App Engine 有您超出的限制。
【解决方案2】:

也许你必须运行

mvn clean package

在部署之前,也许您必须更新您的 gcloud SDK

【讨论】:

    【解决方案3】:

    检查您是否在应用的 appengine-web.xml/app.yaml 或 pom.xml 中启用了以下设置

     <staging>
      <enable-jar-classes>true</enable-jar-classes>
      </staging>
    

    它尝试将所有类捆绑到一个 jar 中,这可能会超出 GCP 施加的限制。 放宽这个设置,可以让你的部署虽然有点慢。

    或者,您可以选择通过 Eclipse GUI 进行部署:

    Project Explorer >> 右键单击​​根节点 >> 部署到 App Engine Standard。

    如果启用设置,这会处理允许的 jar 捆绑,并确保包确实被部署。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-12
      • 2017-04-24
      • 2011-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 2020-05-24
      相关资源
      最近更新 更多