nyximos.log

[Spring Cloud] Could not resolve all files for configuration ':compileClasspath 본문

Programming/Spring

[Spring Cloud] Could not resolve all files for configuration ':compileClasspath

nyximos 2024. 7. 18. 22:10

spring boot로 spring cloud 프로젝트를 만들고 build하니 이런 에러가 떴다.

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find org.springframework.cloud:spring-cloud-starter-config:.
     Required by:
         project :
   > Could not find org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:.
     Required by:
         project :

 

 

버전이 맞지 않기 때문에 버전을 맞춰 주어야 한다.

https://spring.io/projects/spring-cloud

 

Spring Cloud

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, short lived microservices and

spring.io

 

사용중인 spring boot 버전을 확인하자

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

build.gradle

 

  • java: Java 프로젝트를 빌드하는 데 필요한 기본 플러그인
  • org.springframework.boot: Spring Boot 프로젝트를 설정하는 플러그인
  • io.spring.dependency-management: Spring 의존성 관리를 위한 플러그인

 

 


부트 버전에 맞는 링크를 클릭한다.

 

 

 

 

버전 보고 build.gradle에 추가해주자.

ext {
    set('springCloudVersion', "2023.0.3")
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

 

ext : 추가 속성 설정

  • 전역 변수를 선언한다.
  • springCloudVersion 속성을 설정하여 Spring Cloud 의존성의 버전을 정의.

dependencyManagement : 의존성 관리

  • 공통 부모를 상속하는 경우 버전관리를 통합하고 중앙집중화가 가능하다.
  • 해당 코드에서는 Spring Cloud 의존성 관리용 BOM(Bill of Materials)을 가져온다.

 

https://stackoverflow.com/questions/2619598/differences-between-dependencymanagement-and-dependencies-in-maven/37280943#37280943