将项目推送到heroku时,我在maven中遇到错误:
$ git push heroku 枚举对象:718,完成。计数对象:100% (718/718),完成。使用多达 12 个线程的 Delta 压缩压缩对象:100% (439/439),完成。写入对象:100% (718/718),1.16 MiB | 1005.00 KiB/s,完成。总计 718(增量 309),重用 415(增量 165),打包重用 0 远程:压缩源文件...完成。远程:构建源:远程:远程:-----> 在 Heroku-20 堆栈上构建远程:-----> 确定要用于此应用程序远程的构建包:-----> Java 应用程序检测到远程: -----> 安装 OpenJDK 1.8... 远程完成: -----> 执行 Maven 远程: $ ./mvnw -DskipTests clean dependency:list install remote: [INFO] Scanning for projects... .. 。偏僻的:
[INFO] BUILD FAILURE 远程:[INFO] ---------------------------------------------------- -------------------------------- 远程:[INFO] 总时间:10.547 秒远程:[INFO] 完成时间: 2022-07-05T13:53:18Z 远程:[信息]------------------------------------ ------------------------------------远程:[错误]无法执行目标org.apache.maven .plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project springboot_touristsite: Fatal error compile: invalid target release: 11 -> [Help 1] remote:
[ERROR] remote: [ERROR] 查看错误的完整堆栈跟踪,使用 -e 开关重新运行 Maven。远程:[错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。偏僻的:
[ERROR] remote: [ERROR] 有关错误和可能的解决方案的更多信息,请阅读以下文章:remote:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 远程:远程:!错误:无法使用 Maven 远程构建应用程序:
很抱歉,此构建失败!如果您在应用程序代码中找不到问题,请远程:请提交工单以便我们提供帮助:https ://help.heroku.com/远程:远程:!推送被拒绝,无法编译 Java 应用程序。远程:远程:!推送失败的远程:验证部署...远程:远程:!推送到 springbootouristsite 被拒绝。远程:到 https://git.heroku.com/springboottouristsite.git ![远程拒绝] master -> master (pre-receive hook denied) 错误:未能将一些参考推送到“https://git.heroku.com/springboottouristsite.git”
我很尴尬的是正在下载jdk 1.8:
远程:-----> 安装 OpenJDK 1.8... 完成
所以我在application.properties中设置了java.runtime.version=11,我在项目结构中也设置了11,在rum文件中,但是还是下载了1.8
<?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.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zaitsava</groupId>
<artifactId>springboot_touristsite</artifactId>
<version>1.0</version>
<name>springboot_touristsite</name>
<description>springboot_touristsite</description>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<encoding.source>${project.build.sourceEncoding}</encoding.source>
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
<java.source>${maven.compiler.source}</java.source>
<java.target>${maven.compiler.target}</java.target>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我知道 pom 文件中有一些不喜欢的地方,尤其是在 maven 插件中,但是究竟需要更改什么?
通过回答问题得到帮助在项目的根目录中,我创建了带有条目 java.runtime.version=11 的 system.properties 文件