개요
부팅 Spring은 이전 예제에서, 우리는이 부모 POM을 사용합니다.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
부모 지정은 의존 스프링 부팅이 필요합니다. 하지만 가끔은 우리의 프로젝트는 부모,이 시간을 어떻게 처리하는 스프링 부팅을 도입 할 필요가 있다면?
이 문서에서는이 문제를 해결합니다.
부모 POM은 봄 부팅을 도입하는 데 사용되지 않습니다
부모의 pom.xml 주로 거래 관리 및 플러그인의 사용에 따라 달라집니다. 일반적 방법으로 우리의 봄 부팅에 사용되는 사용, 매우 간단합니다.
우리는 어떤 이유로, 봄 부팅을 사용할 수없는 것은 부모와 함께 제공하는 경우 실제로, 우리는이 작업을 수행 할 수 있습니다
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
종속성 dependencyManagement 레이블과 스프링 부팅 종속성 배치 할 수 있습니다. 주 사용 가져 오기에 여기에 범위.
다음으로, 우리는 봄 부팅에 의존 수있는 것은 예를 들어, 사용하는 무료입니다 :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
당신이 부모 POM을 사용하지 않는 경우 반면에, 봄 부팅 플러그인과 함께 제공, 우리는 자신을 소개해야합니다
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
커버 버전 종속성
우리가 사용하고 부모 POM 다른 종속 버전에 정의해야하는 경우에 dependencyManagement을 대체 할 수 있습니다.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.5.5.RELEASE</version>
</dependency>
</dependencies>
// ...
</dependencyManagement>
물론, 당신은 지정된 버전의 도입이 필요 할 때마다에 의존 할 수 있습니다.
더 자습서를 참조하십시오 flydean의 블로그