Spring Boot/[Spring boot] 개발

[Spring boot] java22 → java21 컴파일 변경

재윤 2025. 1. 5. 06:21
반응형
  • 갑자기 이런 에러가 나온다..
  • 찾아보니 현재 자바 22가 베타 버전이라서 그럴 수 있다라고 하는 것임 그래서 자바 21로 컴파일을 진행해보자
Executing pre-compile tasks…
Running 'before' tasks
Checking sources
Parsing java… [Kkrap.main]
java: error: invalid target release: 22
Checking dependencies… [Kkrap.main]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'Kkrap.main'
javac 21.0.2 was used to compile java sources
Finished, saving caches…
Compilation failed: errors: 1; warnings: 0
Executing post-compile tasks…
Synchronizing output directories…
8/16/24, 2:15 PM - Build completed with 1 error and 0 warnings in 333 ms

 

build.gradle

plugins {
	id 'java'
	id 'org.springframework.boot' version '3.3.2'
	id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com'
version = '0.0.1-SNAPSHOT'

java {
	toolchain {
		languageVersion = JavaLanguageVersion.of(21)
	}
}

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
	mavenCentral()
}

dependencies {

	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	compileOnly 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	runtimeOnly 'org.postgresql:postgresql'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

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

 

  • 인텔리J 설정에 들어가서 밑 처럼 바꾸자

 

 

반응형