You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku部署Java 13应用遇UnsupportedClassVersionError问题求助

Fixing UnsupportedClassVersionError with Preview Features on Heroku Java 13 App

Let's break down what's going wrong here and fix it step by step:

1. Fix your system.properties file

Your current system.properties has an invalid configuration for java.runtime.version — this property should only specify the Java version number, not include runtime flags or your main class. Update it to:

java.runtime.version=13

The --enable-preview flag can't be set here; we need to add it to the JVM arguments used to start your app instead.

2. Add --enable-preview to your appassembler-maven-plugin configuration

You're using the appassembler-maven-plugin to generate your startup script, but right now it's not including the preview features flag in the JVM arguments. Modify the <program> section of the plugin to add <jvmArguments>:

<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>
                <!-- Add this line to enable preview features at runtime -->
                <jvmArguments>--enable-preview</jvmArguments>
            </program>
        </programs>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>assemble</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This ensures the generated startup script passes the --enable-preview flag to the JVM when launching your app.

3. Confirm your Maven compiler plugin setup is correct

Your existing maven-compiler-plugin configuration is already correct — it includes <compilerArgs>--enable-preview</compilerArgs> which enables preview features during compilation. This matches your class file version (57.65535, which is Java 13 with preview features), so no changes needed here.

4. Re-deploy your app

After making these changes:

  • Run mvn clean package locally to generate the updated startup script
  • Push your code to Heroku or re-deploy the updated package

Your app should now start successfully with preview features enabled.

内容的提问来源于stack exchange,提问作者Teemitze

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:17:45