#java #spring #spring-boot #maven #heroku
#java #весна #spring-boot #maven #heroku
Вопрос:
Heroku поддерживает open JDK 15 https://devcenter.heroku.com/changelog-items/1887
У меня есть system.properties, которые содержатся java.runtime.version=15
в моем ресурсе. Здесь мой 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.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ma</groupId>
<artifactId>currencyconverter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>currencyconverter</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>15</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- For Json Parser -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- For swagger-annotations -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.17</version>
</dependency>
<!-- springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<!-- springfox-core -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-core</artifactId>
<version>3.0.0</version>
</dependency>
<!-- springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<!-- Swagger dependency -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Когда развертывание начинается в первых нескольких строках журналов Heroku:-
——> Сборка на стеке Heroku-20
—-> Обнаружено Java-приложение
——> Установка JDK 1.8 … выполнено
——> Выполнение Maven
$ ./mvnw -DskipTests очистка зависимости: проверка установки списка
[ИНФОРМАЦИЯ] для проектов…
[ИНФОРМАЦИЯ] Загрузка из центра:
https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.4.3/spring-boot-starter-parent-2.4.3.pom
Почему он устанавливает JDK 1.8?
Последние несколько строк журнала:-
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project currencyconverter: 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
Как мне развернуть приложение JDK 15 в Heroku?
Ответ №1:
У меня есть
system.properties
, который содержитсяjava.runtime.version=15
в моем ресурсе.
Вы поместили его /src/main/resources
в.
Предполагается, что вы должны поместить его в корневую папку /
вашего репозитория git.
В моем случае содержимое my system.properties
находится java.runtime.version=10.0.2
и размещается в корневом каталоге моего репозитория git.
В сборке.войдите в систему сразу после Java app detected
того, как он должен установить указанную версию Java: