> For the complete documentation index, see [llms.txt](https://wannaqueen.gitbook.io/spring5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wannaqueen.gitbook.io/spring5/spring-boot/undefined/13./13.2-maven.md).

# 13.2 Maven

{% hint style="info" %}
메이븐

* 자바 프로젝트의 빌드를 자동화해주는 빌드 툴&#x20;
  * \= 자바 소스를 컴파일하고 패키징해서 디플로이하는 일을 자동으로 해주는 툴
    {% endhint %}

**Maven 사용자는 `spring-boot-starter-parent` 프로젝트를 상속 받아 적절한 기본값을 얻을 수 있습니다.** parent 프로젝트는 다음과 같은 기능을 제공합니다.

{% hint style="info" %}
`spring-boot-starter-parent`를 상속하는게 필수는 아니다. 개인의 선택에 따라 상속하지 않고 직접 필요한 의존성들을 추가하고 관리할 수도 있다.

만약 `spring-boot-starter-parent`를 사용하지 않는다면 스프링부트의 의존성 관리를 지원받지 못하게 된다.(직접 `spring-boot-dependencies`를 import하면 쓸 수 있음) 반드시 그래야 하는 상황이 아니라면 `spring-boot-start-parent`를 사용하는편이 더 편리할 것이다.&#x20;
{% endhint %}

* 기본 컴파일 레벨을 Java 1.8로 지정
* UTF-8 소스 인코딩
* spring-boot-dependencies pom에서 상속받은 [Dependency Management section](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-dependency-management) 섹션은 일반적인 의존성의 버전을 관리합니다. 이 종속성 관리를 사용하면 자신의 pom에서 사용될 때 해당 종속성에 대한 &#x20;

  \<version> 태그를 생략 할 수 있습니다.
* 실행 ID를 사용하여 [`repackage`](https://docs.spring.io/spring-boot/docs/2.1.4.RELEASE/maven-plugin/repackage-mojo.html)[goal](https://docs.spring.io/spring-boot/docs/2.1.4.RELEASE/maven-plugin/repackage-mojo.html) 실행
* 현명한 **자원 필터링** ([resource filtering](https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html))
* 현명한 **플러그인 구성** ([exec plugin](https://www.mojohaus.org/exec-maven-plugin/), [Git commit ID](https://github.com/ktoso/maven-git-commit-id-plugin), and [shade](https://maven.apache.org/plugins/maven-shade-plugin/)).
* 프로필 관련 파일 (예: `application-dev.properties` and`application-dev.yml)`을 포함한`application.properties` and `application.yml` 에 대한 현명한 자원 필터링

`application.properties`및 `application.yml`파일은 Spring 스타일 자리 표시자 (`${…​}`)를 사용할 수 있으므로 Maven 필터링은 `@..@` placeholders를 사용하도록 변경됩니다. (`resource.delimiter`라는 Maven 속성을 설정하여 이를 오버라이드 할 수 있습니다)&#x20;

### 13.2.1 Starter Parent 상속하기

**`spring-boot-starter-parent`에서 상속하도록 프로젝트를 구성하려면 다음과 같이 `parent`를 설정하십시오**:

```markup
<!-- Inherit defaults from Spring Boot -->
<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.1.4.RELEASE</version>
</parent>
```

| ![\[Note\]](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/images/note.png) |
| ------------------------------------------------------------------------------------------------- |
| **이 종속성에 대한 Spring Boot 버전 번호를 지정해야합니다. 추가적인 starters를 임포트 하는 경우 안전하게 버전 번호를 생략 할 수 있습니다.**       |

![](/files/-Lf4-YpkTjrGKyXbsy1N)

**이 설정을 사용하면 프로젝트의 속성을 재정의 하여 개별 종속성을 재정의 할 수도 있습니다.** 예를 들어 다른 Spring Data 버전을 업그레이드하려면 다음을 `pom.xml`에 추가하십시오.&#x20;

```markup
<properties>
	<spring-data-releasetrain.version>Fowler-SR2</spring-data-releasetrain.version>
</properties>
```

| ![\[Tip\]](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/images/tip.png)                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 지원되는 프로퍼티 목록을 [`spring-boot-dependencies` pom](https://github.com/spring-projects/spring-boot/tree/v2.1.4.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml) 에서 확인하십시오. |

###

### 13.2.2 Parent POM 없이 Spring Boot 사용하기

모든 사람들이 `spring-boot-starter-parent` POM을 상속받는 것을 좋아하지는 않습니다. 자신 만의 기업 표준 parent를 사용해야 할 수도 있고, 모든 Maven 설정을 명시적으로 선언하고 싶을 수도 있습니다.&#x20;

**`spring-boot-starter-parent`를 사용하지 않으려는 경우 다음과 같이 `scope=import` 의존성을 사용하여 종속성 관리 (플러그인 관리 제외)의 이점을 계속 유지할 수 있습니다:**

```markup
<dependencyManagement>
		<dependencies>
		<dependency>
			<!-- Import dependency management from Spring Boot -->
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-dependencies</artifactId>
			<version>2.1.4.RELEASE</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>
```

{% hint style="info" %}
스프링부트로부터 dependency management를 "import"한다!
{% endhint %}

**위의 예제 설치에서는 위에 설명 된대로 속성을 사용하여 개별 종속성을 재정의 할 수 없습니다. 동일한 결과를 얻으려면 `dependencyManagement`안에 `spring-boot-dependencies`를 선언하기 전에 원하는 의존 관계의 설정을 먼저 추가해야 합니다.**  예를 들어 다른 Spring Data 버전을 업그레이드하려면 다음 요소를 `pom.xml`에 추가 할 수 있습니다:

```markup
<dependencyManagement>
	<dependencies>
		<!-- Override Spring Data release train provided by Spring Boot -->
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-releasetrain</artifactId>
			<version>Fowler-SR2</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-dependencies</artifactId>
			<version>2.1.4.RELEASE</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>
```

| ![\[Note\]](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/images/note.png) |
| ------------------------------------------------------------------------------------------------- |
| 앞의 예에서는 *BOM*을 지정하지만 모든 종속성 유형을 동일한 방식으로 재정의 할 수 있습니다.                                            |

###

### 13.2.3 Spring Boot Maven Plugin 사용하기&#x20;

**Spring Boot는 프로젝트를 실행 가능한 jar로 패키징 할 수있는** [**Maven plugin**](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-plugin)**을 포함합니다.** 다음 예제와 같이 플러그인을 사용하려면  `<plugins>`섹션에 플러그인을 추가하십시오.

{% hint style="info" %}
메이븐 패키지 단계에서 배포 가능한 jar / war / exe 파일 등을 생성한다.&#x20;
{% endhint %}

```markup
<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>
```

| ![\[Note\]](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/images/note.png) |
| ------------------------------------------------------------------------------------------------- |
| Spring Boot starter parent pom을 사용하는 경우, 플러그인만 추가해야합니다. 상위에 정의 된 설정을 변경하려는 경우가 아니면 구성 할 필요가 없습니다. |
