【问题标题】:Failed to execute goal org.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project (target 11)无法在项目(目标 11)上执行目标 org.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile)
【发布时间】:2020-05-10 02:33:04
【问题描述】:

我尝试部署 spring.io 指南中最简单的应用程序 Guide

但是我有一些麻烦.. 我做了什么:

  1. 已创建项目。 (来自 spring.io 教程)
  2. 已下载 heroku CLI
  3. 在 IntellijIdea 中打开终端
    3.1 git 初始化
    3.2 git add .
    3.3 git commit -m "fd"
    3.4 git远程添加heroke 'url'
    3.5 git push heroku master
  4. 在最后一条命令之后出现此错误:
remote:        [INFO] BUILD FAILURE
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  12.608 s
remote:        [INFO] Finished at: 2020-01-23T18:20:18Z
remote:        [INFO] ------------------------------------------------------------------------
remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project milliapp: Fatal error compiling: invalid target release: 11 -> [Help 1]
remote:        [ERROR]
remote:        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote:        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote:        [ERROR]
remote:        [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote:        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
remote:
remote:  !     ERROR: Failed to build app with Maven
remote:        We're sorry this build is failing! If you can't find the issue in application code,
remote:        please submit a ticket so we can help: https://help.heroku.com/
remote:
remote:  !     Push rejected, failed to compile Java app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to deploymilliapp.
remote:
To https://git.heroku.com/deploymilliapp.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/deploymilliapp.git'

【问题讨论】:

    标签: spring spring-boot maven heroku deployment


    【解决方案1】:

    问题是您告诉 maven 使用 JDK 11 来构建您的应用程序,但您的 java_home 设置为不同的版本。将您的 java_home 环境变量更改为您的 java 11 安装,它将在 11 中构建。

    【讨论】:

      【解决方案2】:

      如果使用 intelij,

      1. 制作system.properties文件,放到根目录下(pom.xml所在)
      2. 在此文件中,写入适当的版本,例如
        java.runtime.version=11
        maven.version=3.6.2
      3. 再次部署 在此步骤中,阅读日志文件以查看 JDK 12 是由 heroku 安装的

      【讨论】:

        【解决方案3】:

        你必须“告诉” Heroku,你想在 Java 11 上运行你的应用程序。为此,将 system.properties 文件添加到你的项目中(我是在主目录中完成的)并在其中放入以下行:

        java.runtime.version=11
        

        它对我有用。

        【讨论】:

        【解决方案4】:

        在 pom.xml 文件中,在属性标签中的行下面注释。

        <java.version>11</java.version>
        

        它对我有用。

        【讨论】:

          【解决方案5】:

          第二种解决方案:

          1. 将应用程序降级到 java 8
          2. maven-compiler-plugin 3.8.1 与该配置一起使用:
             <plugins>
                      <plugin>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-maven-plugin</artifactId>
                      </plugin>
                      <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <version>3.8.1</version>
                          <configuration>
                              <source>8</source>
                              <target>8</target>
                              <testSource>8</testSource>
                              <testTarget>8</testTarget>
                              <showDeprecation>true</showDeprecation>
                              <compilerArgument>-Xlint:unchecked</compilerArgument>
                          </configuration>
                      </plugin>
                  </plugins>
          

          【讨论】:

            【解决方案6】:

            解决了。 删除了这部分代码

            <properties>
            <java.version>11</java.version>
            

            【讨论】:

              猜你喜欢
              • 2021-10-19
              • 2018-03-04
              • 2016-08-06
              • 1970-01-01
              • 2020-03-24
              • 2020-07-29
              • 2017-06-23
              • 1970-01-01
              • 2021-03-11
              相关资源
              最近更新 更多