java - java错误:在heroku上部署时构建失败
问题描述
当我运行以下命令时:
git push heroku master
我收到以下错误:
remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar (21 kB at 1.1 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 404 kB/s) remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 4.0 MB/s) remote: [INFO] Changes detected - recompiling the module! remote: [INFO] Compiling 4 source files to /tmp/build_ca81690e12aa9ecc064d62f3524c8370/target/classes remote: [INFO] ------------------------------------------------------------------------ remote: [INFO] BUILD FAILURE remote: [INFO] ------------------------------------------------------------------------ remote: [INFO] Total time: 11.868 s remote: [INFO] Finished at: 2020-06-03T12:05:45Z remote: [INFO] ------------------------------------------------------------------------ remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project coronavirus-tracker: Fatal error compiling: invalid target release: 12 -> [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 covid2020global. remote: To https://git.heroku.com/covid2020global.git
更新:
Maven 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.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.javabrains</groupId>
<artifactId>coronavirus-tracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>coronavirus-tracker</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>12</java.version>
</properties>
<dependencies>
<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.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
</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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<appName>coronavirus-tracker-master</appName>
</configuration>
</plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
解决方案
我终于解决了删除 Java 8 的 JRE 路径的问题。之后,maven 终于找到了 JDK 13 的路径。我用这个命令 mvn -v 进行了检查。在这些操作之后,我成功地将我的项目部署到 Heroku!
推荐阅读
- r - 如何强制 model.matrix/model.Matrix() 保持因子水平的原始顺序......?
- java - 我不知道如何使用 JPQL [AND] 和 [OR]
- javascript - 如何在javascript中拖动d3.js中的节点?
- android - 如何从 Firebase 实时数据库检索数据到 mySqlite?
- google-apps-script - 我可以将工作表下载到特定的计算机硬盘驱动器,或者将备份和同步中的工作表移动到硬盘驱动器吗?
- sql - 如何检查服务器上是否存在给定的数据库?
- jupyter-notebook - Jupyter 实验室无法启动
- c++ - _mm256_permutexvar_epi8 和 _mm256_permutexvar_epi16 AVX2 等价物用于编译时间常数洗牌吗?
- html - 悬停时暂停向上滚动
- python - 将 'path('accounts/',include('django.contrib.auth.urls'))' 添加到 django 项目的 urls.py 文件有什么意义?