spring-bootmaven-3intellij-14

java: error: invalid source release: 15 SpringBoot application


I'm building a simple springboot application with IntelliJ. This is my pom.xml file.

<?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>3.1.9</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>it.michelecastriotta</groupId>
    <artifactId>SimpleWebApp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>SimpleWebApp</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </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>
                <configuration>
                    <image>
                        <builder>paketobuildpacks/builder-jammy-base:latest</builder>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

If I try to build the application, I have the following error:

enter image description here

What can I do to fix the error?


Solution

  • Spring Boot 3 requires at least Java 17 so you'll need to use Java 17 or higher or use Spring Boot 2.7.x if you want to continue using Java 8.