Error deploying my Spring boot project on Heroku (invalid target release)

此生再无相见时 提交于 2021-01-28 05:47:37

问题


// Pom.xml file

4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.3.RELEASE com.SpringBootJavaProject LearningProject 0.0.1-SNAPSHOT LearningProject Demo project for Spring Boot

<properties>
    <java.version>14</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            </plugin>

        <plugin>
            <groupId>com.heroku.sdk</groupId>
            <artifactId>heroku-maven-plugin</artifactId>
            <version>3.0.3</version>
        </plugin>
    </plugins>


</build>

// Error Desciption [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project LearningProject: Fatal error compiling: invalid target release: 14 -> [Help 1]


回答1:


Heroku uses OpenJDK 8 as default.

Change to use Java 8 or set your desired Java version in the system.properties file (at the root of your project), the file should contain:

java.runtime.version=14


来源:https://stackoverflow.com/questions/63805455/error-deploying-my-spring-boot-project-on-heroku-invalid-target-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!