sabari
sabari

Reputation: 2625

Getting SpringBoot error - Execution failed for task ':compileJava

The below is my build.gradle.

When I Bootrun, i get the error Execution failed for task ':compileJava invalid source release: 18

plugins {
    id 'org.springframework.boot' version '2.6.9'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.loginapp'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '18'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

enter image description here

Upvotes: 1

Views: 1735

Answers (1)

Ausgefuchster
Ausgefuchster

Reputation: 1178

Since you're using IntelliJ, shared the screenshot and told us you alread checked the java version and I already got this error a few times here is my TODO I go through when I get this error:

  1. Do what you showed us on the screenshot (Check Project Version and language level)
  2. Do the same for Modules (Project Structure > Modules) Don't forget the Dependencies Tab there you can find the module SDK
  3. Check Java Compiler (Settings > Build, Execution, Deployment > Compiler > Java Compiler) there you can see a Project bytecode version & Per-module bytecode version -> Check those

Hope this works :)

Upvotes: 1

Related Questions