스프링/스프링부트개념과 활용

의존성 관리 이해

bbangduck 2023. 3. 30. 16:02

스프링부트 소개

Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run. We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

 

출처

https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#getting-started-introducing-spring-boot

 

 

프로젝트 생성

프로젝트 생성

여러 방법 중 spring initializr를 이용해 프로젝트를 생성해 줬습니다.

https://start.spring.io/

 

 

 

스프링 부트는 스프링 애플리케이션을 만들 때에 필요한 초기 설정을 간편하게 해주는 프레임워크입니다.

springboot에서 의존성 버전들을 관리해주기 때문에 개발자들이 신경쓸 필요가 없습니다.

특정 버전을 사용하고 싶다면 명시해주시면 됩니다.

 

spring-boot-starter의 부모인 spring-boot-dependency에 들어가면 

properties 버전들이 적혀있고 depandencyManagement 에 의존성들이 정의돼 있습니다.

 

 

만약 프로젝트에 상속 구조가 따로 있어서 parent를 선언하지 못하는 경우에는 두가지 방법이 있습니다.

현재 parent의 parent 를 spring-boot-starter-parent로 선언합니다.

두번째 방법은 dependencyManagements 이용하기 입니다.

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

출처

https://docs.spring.io/spring-boot/docs/3.0.5/maven-plugin/reference/htmlsingle/

 

하지만 첫번째 방법이 두번째 방법보다 더 많은 걸 설정해준다고 합니다.

 

스프링부트 이전에는 이 많은 설정들을 직접 해줘야 했다니 믿기지 않네요. 

그럼 읽어주셔서 감사합니다.

'스프링 > 스프링부트개념과 활용' 카테고리의 다른 글

자동설정이해  (0) 2023.04.27
의존성 관리 응용  (0) 2023.03.31