java.lang.UnsupportedClassVersionError heroku部署
我在hero上有一个应用程序,我把它翻译成了13个Java 它已成功编译,但由于以下错误而无法启动:java.lang.UnsupportedClassVersionError heroku部署,java,heroku,Java,Heroku,我在hero上有一个应用程序,我把它翻译成了13个Java 它已成功编译,但由于以下错误而无法启动: 2019-10-19T10:22:41.678012+00:00 app[worker.1]: Error: LinkageError occurred while loading main class Main 2019-10-19T10:22:41.678050+00:00 app[worker.1]: java.lang.UnsupportedClassVersionError:
2019-10-19T10:22:41.678012+00:00 app[worker.1]: Error: LinkageError occurred while loading main class Main
2019-10-19T10:22:41.678050+00:00 app[worker.1]: java.lang.UnsupportedClassVersionError: Preview features are not enabled for Main (class file version 57.65535). Try running with '--enable-preview'
在heroku中,编写它是为了在system.properties中注册java版本
我做到了
java.runtime.version=13 --enable-preview Main
我还更改了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>TelegramBot</groupId>
<artifactId>TelegramBot</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.release>13</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<assembleDirectory>target</assembleDirectory>
<programs>
<program>
<mainClass>Main</mainClass>
<name>teemitze-anna-bot</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>13</release>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-httpclient/commons-httpclient -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/appassembler-maven-plugin -->
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.telegram/telegrambots -->
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.4.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
</dependencies>
</project>
原因可能是什么?谢谢! 您的系统中不属于启用预览的属性。通过运行以下命令,尝试将其添加到\u JAVA\u OPTIONS
:
$ heroku config:set _JAVA_OPTIONS="--enable-preview"
或者,如果您有Procfile
,也可以将其放入java
命令中。启用预览的不属于您的系统。属性
。通过运行以下命令,尝试将其添加到\u JAVA\u OPTIONS
:
$ heroku config:set _JAVA_OPTIONS="--enable-preview"
或者您可以将其放入Procfile
中的java
命令中(如果有)。您还必须在heroku上启用预览功能。尝试heroku运行java——启用预览…
您还必须在heroku上启用预览功能。尝试运行java——启用预览…