使用 Heroku 使用 Maven 构建应用程序时出错 [英] Error When Building App with Maven Using Heroku
问题描述
我正在尝试使用 Heroku 部署我的 Discord 机器人,但每次我部署它时,它都会给我一个错误.该代码使用 IntelliJ Idea 在本地工作.任何人都可以帮我纠正这个错误吗?
I'm trying to deploy my Discord bot using Heroku but everytime I deploy it, it gives me an error. The code works on local using IntelliJ Idea. Can anyone help me correct this error please?
构建日志:
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 21 source files to /tmp/build_8fdb6208/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.237 s
[INFO] Finished at: 2021-03-21T23:52:06Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project CalciteDiscordBot: Fatal error compiling: invalid target release: 15 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
这是我的 pom.xml:
Here's my 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>org.example</groupId>
<artifactId>CalciteDiscordBot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>15</maven.compiler.target>
<maven.compiler.source>15</maven.compiler.source>
</properties>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_168</version>
</dependency>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</project>
推荐答案
您的应用程序需要 Java 15 (<maven.compiler.source>15</maven.compiler.source>
) 所以你需要告诉 Heroku 你想要那个特定的 Java 版本(而不是默认版本)
You application requires Java 15 (<maven.compiler.source>15</maven.compiler.source>
) so you need tell Heroku you want that specific Java version (instead of the default one)
在根文件夹中放置一个文件 system.properties:
In the root folder place a file system.properties:
java.runtime.version=15
这篇关于使用 Heroku 使用 Maven 构建应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!