새소식

반응형
Development

[Gradle] dependency 관리 (related with maven bom)

  • -
반응형

 

스프링 부트 애플리케이션에서 dependency를 관리하는 방법은 2가지이다

  • io.spring.dependency-management plugin 이용
  • gradle native bom 지원 이용
  • plugin에서 제공하는 property를 이용하여 버전 등의 customizing 가능

plugin : https://plugins.gradle.org/plugin/io.spring.dependency-management

plugins { id 'org.springframework.boot' version '2.7.17' id 'io.spring.dependency-management' version '1.0.15.RELEASE' } dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.kafka:spring-kafka' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.mysql:mysql-connector-j' runtimeOnly 'io.micrometer:micrometer-registry-prometheus' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.kafka:spring-kafka-test' testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' }

 

위와 같이 설정하면, spring-boot에서 관리하는 dependency의 경우에는 버전 정보를 명시해 줄 필요가 없다.

해당 spring-boot에서 사용하고 있는 버전은 아래의 링크에서 확인 가능하다

https://docs.spring.io/spring-boot/docs/current/reference/html/dependency-versions.html

{{current}}에 해당하는 정보를 사용하고있는 spring-boot 버전으로 설정 

 

  • build 속도가 빠르다
dependencies { implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.17') }

 

 

관련 가이드 : https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#managing-dependencies

반응형

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.