当前位置: 首页 > 知识库问答 >
问题:

将springboot应用程序推送到heroku时出错

钱均
2023-03-14

我试图在Heroku上推动我的Spring Boot应用程序,我得到了一个错误:未能用Maven构建应用程序,即未能执行目标org.apache.Maven.plugins:maven-compiler-plugin:3.8.1:compile(default-compile)on project BlogApplication:致命错误编译:无效的目标版本:11。

日志:

 8.8 MB/s)
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.4/plexus-compiler-api-2.8.4.jar (27 kB at 694 kB/s)
remote:        [INFO] Changes detected - recompiling the module!
remote:        [INFO] Compiling 26 source files to /tmp/build_bde72765/target/classes
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD FAILURE
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  14.367 s
remote:        [INFO] Finished at: 2020-12-26T03:02:12Z
remote:        [INFO] ------------------------------------------------------------------------
remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project BlogApplication: 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:  !
remote:  ! ## Warning - The same version of this code has already been built: a12b93ea38df794a63db75682e8389ef779ed088
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version a12b93ea38df794a63db75682e8389ef779ed088
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to blog-application-mvc.
remote: 
To https://git.heroku.com/blog-application-mvc.git
 ! [remote rejected] master -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/blog-application-mvc.git'

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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.blog</groupId>
    <artifactId>BlogApplication</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>BlogApplication</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.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-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    <!--    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>-->

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

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

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

</project>

共有1个答案

沈凯康
2023-03-14

Heroku提供了一个Java 8运行库,如果需要,您可以更改它。
在项目的根目录中创建一个文件system.properties,其中包含:

java.runtime.version=11
 类似资料:
  • 我正在尝试将我的应用程序部署到Heroku,但似乎存在一些问题。每次我尝试: 我的heroku日志告诉我,我的应用程序崩溃了,我错过了“调试器”宝石。我在Heroku上找到了这条线索和这一页。当我尝试安装“byebug”gem时,bundle告诉我它不会安装在Ruby 1.9.3上,当我按照Heroku的建议将“debugger”gem放在gem文件的开发组中时,我仍然会收到相同的错误。 我也更新

  • 我有一个vuejs应用程序,它是用vue cli设置的,我正在尝试将我的应用程序部署到Heroku。 这是我的服务器: 我从gitignore中删除dist, 我在package.json中添加了一个类似“start”的起始点:“node server.js” 以下是我在控制台看到的内容: 加载资源失败:服务器响应,状态为503(服务不可用)/Favicon.ico:1 以下是heroku日志:

  • 在Heroku上部署Node.js应用程序时,我遇到以下错误。 2017-04-18T18:40:10.158442+00:00APP[Web1]:npm错误!请在任何支持请求中包含以下文件: 2017-04-18T18:40:10.158544+00:00APP[Web1]:npm错误!/app/npm-debug.log 2017-04-18T18:40:10.237236+00:00 Her

  • 我想使用heroku pg:push命令将本地postgresql数据库推送到heroku。命令如下所示: 。 我的应用程序的名称是。我尝试了。输出是: 我很惊讶我没有在数据库中输入任何内容。但我仍然运行heroku pg:reset DATABASE来重置我的数据库。之后,我再次尝试了heroku pg:推送mysitedb数据库——app secure-gorge-4090,但输出仍然相同。

  • 2020-06-26T09:26:58.880610+00:00Heroku[web.1]:状态从开始更改为>崩溃2020-06-26T12:16:58.291701+00:00Heroku[web.1]:状态从崩溃更改为>开始2020-06-26T12:17:05.611518+00:00Heroku[web.1]:用命令启动进程>2020-06-26T12:17:08.625648+00:00

  • 问题内容: 我正在尝试在Heroku上使用Flask开发我的第一个“大型”应用程序,并尝试将此处的基本教程与以下说明结合:https : //devcenter.heroku.com/articles/python与以下说明:http:// flask.pocoo.org/docs/patterns/packages/#larger- applications。它在本地与“先行启动”一起工作,但是