Spring Boot 가 열 리 는 두 가지 방식 에 대한 상세 한 설명

3295 단어 SpringBoot열다
스프링 부 트 의존
Spring Boot 를 사용 하 는 것 은 간단 합 니 다.기본 의존 팩 을 먼저 추가 하고 다음 과 같은 두 가지 방법 이 있 습 니 다.
1.spring-boot-starter-parent 프로젝트 계승

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.5.6.RELEASE</version>
</parent>
2.spring-boot-dependencies 항목 의존 가 져 오기

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>1.5.6.RELEASE</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
</dependencyManagement>

Spring Boot 의존 주의 점
1.속성 오 버 레이 는 계승 에 만 유효
This only works if your Maven project inherits (directly or indirectly) from spring-boot-dependencies. If you have added spring-boot-dependencies in your own dependencyManagement section withimportyou have to redefine the artifact yourself instead of overriding the property.
Spring Boot 의존 패키지 에 있 는 구성 요소 의 버 전 은 현재 Spring Boot 와 연결 되 어 있 습 니 다.구성 요소 의 버 전 을 수정 하려 면 다음 과 같은 속성 으로 덮어 쓰 면 됩 니 다.그러나 이 방식 은 계승 에 만 유효 하고 가 져 오 는 방식 이 잘못 되 었 습 니 다.

<properties>
  <slf4j.version>1.7.25<slf4j.version>
</properties>
가 져 오 는 방식 이 버 전의 업 그 레이 드 를 실현 하고 위의 효 과 를 얻 으 려 면 업그레이드 할 구성 요 소 를 Spring Boot 전에 의존 할 수 있 습 니 다.

<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>
      <scope>import</scope>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>1.5.6.RELEASE</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues.
Spring Boot 의 의존 구성 요소 버 전 을 수정 하려 면 호 환 되 지 않 는 문제 가 발생 할 수 있 습 니 다.

2.자원 파일 필터 문제
계승 Spring Boot 를 사용 할 때 Maven resource filter 를 사용 하여 자원 파일 을 걸 러 내 려 면 자원 파일 에 있 는 자리 표시 자 는${}과 Spring Boot 를 구별 하기 위해@...@으로 싸 야 합 니 다.그렇지 않 으 면 유효 하지 않 습 니 다.또한,@...@자리 차지 문 자 는 Yml 파일 편집기 에서 컴 파일 이 잘못 되 었 기 때문에 계승 방식 을 사용 하 는 데 많은 문제 가 있 습 니 다.구 덩이 는 천천히 걸 어야 합 니 다.
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기