## 스타터의 중요성
스프링 부트의 장점을 세 가지만 이야기하라고 한다면, 보통 다음 세 가지가 꼽힌다.
>1. [[6. Spring Boot와 특징 🌿#단독 실행 가능한 스프링 애플리케이션|내장 WAS로 간단한 배포]]
>2. AutoConfiguration을 통한 간편한 설정
>3. Spring Boot Starter를 통한 간편한 의존성 관리
여기서 앞의 두 가지 장점은 **스프링** 프레임워크 사용 경험이 있으면 쉽게 체감 된다. 그러나 마지막 'Spring Boot Starter를 통한 간편한 의존성 관리'는 스프링 프레임워크를 정제된 학습 자료(책, 강의 등)와 같이 사용했다면 체감하기 힘들 수도 있다. 학습 자료에서는 의존성 충돌이 일어나지 않도록 라이브러리 사용을 지시하기 때문이다. 그래선지 과거 프로젝트를 같이 하던 팀원 중 한 명이 내게 왜 'Spring Boot Starter를 통한 간편한 의존성 관리'가 세 가지 장점 중 하나인지 물어본 적이 있다. 이 질문에 답하려면 먼저 **의존성 지옥**에 대해 말할 필요가 있다.
### 의존성 지옥(Dependecy Hell)
![[Pasted image 20231207105243.png]][이미지 출처](https://medium.com/javarevisited/spring-dependency-hell-understanding-the-risks-and-best-practices-to-avoid-them-f7c24fae5302)
다음 상황을 가정해보자.
> - 어떤 애플리케이션에서 A 라이브러리와 B 라이브러리를 사용한다.
> - 두 라이브러리는 각각 C 라이브러리의 `1.0` 버전과 `2.0` 버전을 사용한다.
> - C 라이브러리의 `2.0` 버전에서 특정 메서드의 반환형이 달라졌다. 또는 메서드가 사라졌다.
이런 경우 런타임에서 `IncompatibleClassChangeError` 나 `NoSuchMethodError` 가 일어나 애플리케이션이 죽어버린다. 개인 프로젝트거나 개발 단계라면 이런 상황은 그저 귀찮은 상황에 불과하지만, 실제 배포 중인 엔터프라이즈 애플리케이션에서 이런 상황은 매우 심각한 문제가 된다. 따라서 라이브러리 간의 버전 또는 호환성 충돌을 미리 확인하고 방지해야 하는데, 이를 **의존성 관리** 작업이라고 한다.
문제는 엔터프라이즈 애플리케이션 수준에서는 외부 라이브러리를 수십 개, 수백 개도 사용한다는 점이다. 이런 경우 개발자가 일일이 라이브러리 간의 버전/호환성 충돌을 확인하고 처리하는 것은 매우 고된 일이다. 이런 맥락에서 탄생한 용어가 **의존성 지옥**이다.
### 스프링 부트 스타터 = 의존성 작업이 끝난 라이브러리 묶음
스프링 부트 스타터는 의존성 관리 작업을 끝낸 라이브러리 묶음이다. 수 많은 컨트리뷰터들이 라이브러리 간의 버전/호환성 충돌을 확인하고, 에러 여부를 테스트하고, 설정까지 해뒀기 때문에 버전/호환성 충돌이 거의 일어나지 않는다.
덕분에 스프링 부트 개발자들은 의존성 지옥을 신경 쓰지 않고, 오로지 개발에만 집중할 수 있는 것이다. 웹 관련 프로젝트를 한다? 그럼 그냥 웹 관련 스프링 부트 스타터(`spring-boot-starter-web` 등)를 찾아서 의존성에 추가하기만 하면 된다.
### 세스코와 스프링 부트 스타터의 공통점
**스프링 부트 스타터를 통해서만 의존성을 관리하다보면, 아이러니하게 스프링 부트 스타터의 편리함을 의식하기 힘들다**. 이런 상황을 보고 있으면 세스코가 떠오른다.
지금의 세스코는 해충 박멸 기업으로 알려져 있지만, 사실 세스코가 처음 설립되었을 때는 쥐🐭를 잡는 기업이었다. **문제는 쥐를 너무 잘 잡아서 씨를 말리는 바람에 사람들이 더 이상 쥐를 잡아야 한다는 생각을 안 하게 됐다는 점이다**. 이로 인해 위기가 온 세스코가 선택한 다음 사업이 해충 박멸이었고, 지금은 해충 박멸 회사로 알려져 있다.
이런 맥락에서 다음과 같이 말할 수 있겠다.
>**스프링 부트 스타터를 통한 의존성 관리가 얼마나 편리하냐고? 사람들이 스프링 부트 스타터를 통해 의존성 관리를 해야 한다는 사실을 모를 정도로 편리하다!**
## 주요 스타터와 포함된 라이브러리
| Starter 이름 | 포함된 주요 라이브러리 목록 |
|-------------------------------|------------------------------------------------------|
| `spring-boot-starter` | [Spring Core](https://docs.spring.io/spring-framework/docs/current/reference/html/core.html), [Embedded Tomcat](https://tomcat.apache.org/tomcat-9.0-doc/), [spring-context](https://docs.spring.io/spring-framework/docs/current/reference/html/core.html) |
| `spring-boot-starter-web` | [Spring MVC](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html), [Embedded Tomcat](https://tomcat.apache.org/tomcat-9.0-doc/), [spring-web](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html) |
| `spring-boot-starter-data-jpa` | [Spring Data JPA](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/), [Hibernate](https://hibernate.org/), [spring-orm](https://docs.spring.io/spring-framework/docs/current/reference/html/orm.html) |
| `spring-boot-starter-security` | [Spring Security](https://docs.spring.io/spring-security/site/docs/current/reference/html5/), [spring-aop](https://docs.spring.io/spring-framework/docs/current/reference/html/aop.html)|
| `spring-boot-starter-data-rest`| [Spring Data REST](https://docs.spring.io/spring-data/rest/docs/current/reference/html/), [Spring HATEOAS](https://docs.spring.io/spring-hateoas/docs/current/reference/html/) |
| `spring-boot-starter-thymeleaf`| [Thymeleaf](https://www.thymeleaf.org/), [spring-boot-starter-web](https://docs.spring.io/spring-boot/docs/current/reference/html/web.html) |
| `spring-boot-starter-test` | [spring-boot-test](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html), [JUnit](https://junit.org/junit5/docs/current/user-guide/), [Spring Test](https://docs.spring.io/spring-framework/docs/current/reference/html/testing.html), [AssertJ](https://assertj.github.io/doc/), [Hamcrest](http://hamcrest.org/JavaHamcrest/), [Mockito](https://site.mockito.org/) |
| `spring-boot-starter-cache` | [Spring Cache Abstraction](https://docs.spring.io/spring-framework/docs/current/reference/html/cache.html), [Ehcache](https://www.ehcache.org/) |
| `spring-boot-starter-data-redis`| [Spring Data Redis](https://docs.spring.io/spring-data/redis/docs/current/reference/html/), [Lettuce](https://lettuce.io/) |
| `spring-boot-starter-mail` | [JavaMail API](https://javaee.github.io/javamail/) |
| `spring-boot-starter-actuator` | [Production ready features, monitoring, management](https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html) |
## 스타터 적용 방법 (Gradle 🐘)
```groovy
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
...
}
```