레벨업 일지

[에러] failed :compileJava 본문

JAVA/spring

[에러] failed :compileJava

24시간이모자란 2023. 2. 7. 01:54

문제

빌드 에러가 났다. 

다음과 같이 빨간 화면이 나왔다.

! 실패

원인

build.gradle 에서 jdk 버전이 인텔리제이 프로젝트에서 설정한 버전과 동일하지 않았다. 

ctrl+shift + alt + s 를 눌러 프로젝트의 sdk 버전은 11로 설정됐고 

build.gradle 파일의 자바 버전은 1.8이었다. 

sourceCompatibility = 1.8

해결

다음과 같이 프로젝트 내부 버전이랑 그래이들 jdk 버전을 똑같이 설정해주었다.

buildscript{
    ext{
        springBootVersion = '2.1.7.RELEASE'
    }
    repositories{
        mavenCentral()
        jcenter()
    }
    dependencies{
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
apply plugin:'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group 'com.jojoldu.book'
version '1.0-SNAPSHOT'
sourceCompatibility = 11

repositories {
    mavenCentral()
}

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
    implementation('org.projectlombok:lombok:1.18.24')
}
Comments