SpringBoot
SpringBoot-의존성(pom.xml)-버전관리
✨✨✨✨✨✨✨
2021. 8. 22. 23:18
반응형
3부 스프링 부트는 어떻게 버전관리를 할까?
1. 의존성 관리 이해
pom.xml파일로 들어가보면 parent라는 코드가 있습니다.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
- spring-boot-starter-parent를 Alt+Click 하면
spring-boot-starter-parent-2.0.3.RELEASE.pom 이라는 파일이 나옵니다.
spring-boot-starter-parent-2.0.3.RELEASE.pom
아래 내용은 해당 파일의 일부입니다. 아래 내용처럼 환경설정 파일을 관리해주고
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>
<!-- 생략 -->
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/application*.yml</include>
<include>**/application*.yaml</include>
<include>**/application*.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/application*.yml</exclude>
<exclude>**/application*.yaml</exclude>
<exclude>**/application*.properties</exclude>
</excludes>
</resource>
</resources>
spring-boot-dependencies를 Ctrl + Click해서 한번 더 올라가보면 아래 파일로 이동됩니다.
아래 파일은
- spring-boot-dependencies-2.0.3.RELEASE.pom
아래 내용은 해당 파일의 일부이다.
내용처럼 pom.xml에 명시된 dependency들의 버전관리를 직접해주기 때문에, 버전을 명시할 필요가 없습니다.
<properties>
<activemq.version>5.15.4</activemq.version>
<antlr2.version>2.7.7</antlr2.version>
<appengine-sdk.version>1.9.64</appengine-sdk.version>
<artemis.version>2.4.0</artemis.version>
<aspectj.version>1.8.13</aspectj.version>
<assertj.version>3.9.1</assertj.version>
<atomikos.version>4.0.6</atomikos.version>
<bitronix.version>2.1.4</bitronix.version>
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
<byte-buddy.version>1.7.11</byte-buddy.version>
2. 의존성 관리 응용
첫번째, 정말 버전관리를 해주는지 확인
버전을 관리해주는지 확인해보기 위해 아래 내용처럼 입력하고 버전은 명시하지 않겠습니다.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
pom.xml에 위 내용을 입력하면
왼쪽에 동그란 아이콘이 생기고(상위 parent pom에서 버전관리를 해주고 있다는 증거) 자동으로우측의 Maven에 해당 jar 파일이 spring-boot-dependencies-2.0.3.RELEASE.pom에 관리되고있는 버전으로 추가가됩니다. (빨간색 참조)

나. parent에서 버전관리 안하는 dependency
위 그림에 파란색을 참조해보면
아래 내용을 입력했을 경우 왼쪽에 동그란 아이콘이 표시되지않기에 버전관리가 안됨을 알 수 있습니다.(파란색)
<!-- https://mvnrepository.com/artifact/org.modelmapper/modelmapper -->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.1.0</version>
</dependency>


다. parent에서 버전은 관리해주지만 강제로 버전바꾸기
spring-boot-dependencies-2.0.3.RELEASE.pom 해당 파일에서 spring-version을 관리해주고있지만, 명시적으로 pom.xml에서 5.0.6이라고 입력 해주면 오버라이딩 되어 우측 화면처럼 버전이 변경됨을 알 수 있다.


반응형