[英]Heroku ignores system.properties file and does not change jdk version
I'm trying to deploy jsp project on Heroku and I followed the guide https://devcenter.heroku.com/articles/java-webapp-runner#create-a-procfile .我正在尝试在 Heroku 上部署 jsp 项目,我遵循了指南https://devcenter.heroku.com/articles/java-webapp-runner#create-a-procfile 。 When I tried to deploy, Heroku used jdk 1.8 (i need 17 in my project).
当我尝试部署时,Heroku 使用 jdk 1.8(我的项目需要 17)。 So I created a
system.properties
file with the line java.runtime.version=17
, commited and pushed it to master, but Heroku still tries to use jdk 1.8.所以我创建了一个
system.properties
文件,其中包含java.runtime.version=17
行,提交并将其推送到 master,但 Heroku 仍然尝试使用 jdk 1.8。 What am I doing wrong?我究竟做错了什么?
pom.xml: 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>
<groupId>com.ruskaof</groupId>
<artifactId>lab2WildFly</artifactId>
<version>1.0-SNAPSHOT</version>
<name>lab2WildFly</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.heroku</groupId>
<artifactId>webapp-runner</artifactId>
<version>9.0.52.1</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Procfile:简介:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
Two things:两件事情:
System properties file should be at root level of the project.系统属性文件应该位于项目的根级别。 Refer: https://github.com/heroku/java-getting-started
参考: https://github.com/heroku/java-getting-started
If that does not work for you you can instead use maven deployment如果这对您不起作用,您可以改为使用 maven 部署
In your pom.xml goto section add following在你的 pom.xml 转到部分添加以下内容
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.3</version>
<configuration>
<jdkVersion>17</jdkVersion>
</configuration>
</plugin>
if you do not want to use procfile as well you can add config for that as well in configuration section.如果您也不想使用 procfile,您也可以在配置部分为此添加配置。
<configuration>
...
<processTypes>
<web>java $JAVA_OPTS -cp target/classes:target/dependency/* Main</web>
</processTypes>
</configuration>
also you will see configuration for java opts there if required Ref: https://devcenter.heroku.com/articles/deploying-java-applications-with-the-heroku-maven-plugin如果需要,您还将在那里看到 java 选择的配置参考: https://devcenter.heroku.com/articles/deploying-java-applications-with-the-heroku-maven-plugin
If you want to understand or customize and use any other java version you can have a look at: https://devcenter.heroku.com/articles/java-support#specifying-a-java-version如果您想了解或自定义和使用任何其他 java 版本,您可以查看: https://devcenter.heroku.com/articles/java-support#specifying-a-java-version
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.