본문 바로가기

ProblemSolving

[SpringBoot] 프로젝트 생성 후 빌드 실패

Java 11

Spring Boot 3.0.1

 

오류 메세지

A problem occurred configuring root project 'shop'.

> Could not resolve all files for configuration ':classpath'.

> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1.

Required by:

project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1

> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:

- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally:

- Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11

 

해결 방법

Spring Boot 2.x -> Java 11

Spring Boot 3.x -> Java 17

 

build.gradle 수정

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

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'