POM 최적화 (5)

POM 의 절 차 를 최적화 하 다.
1. 위로 이동 에 의존
 다 중 키 module 에서 같은 dependency 를 사용 하면 부모 POM 에서 추출 할 수 있 습 니 다.예: spring 과 hibenate - annotations 같은 의존 도가 여러 모듈 에서 밝 혀 졌 습 니 다.모든 hibenate 의존 은 자바 x. transaction 을 반복 적 으로 제거 합 니 다.이러한 의존 설정 이 위로 이동 한 후에 우 리 는 모든 POM 에 의존 하 는 버 전 을 제거 해 야 합 니 다. 그렇지 않 으 면 부모 프로젝트 에 정 의 된 dependency Management 를 덮어 씁 니 다.
부모 POM:
<dependencyManagement>
 <dependencies>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring</artifactId>
   <version>2.0.7</version>
  </dependency>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-annotations</artifactId>
   <version>3.3.0.ga</version>
  </dependency>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-commons-annotations</artifactId>
   <version>3.3.0.ga</version>
  </dependency>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate</artifactId>
   <version>3.2.5.ga</version>
   <exclusions>
    <exclusion>
     <groupId>javax.transaction</groupId>
     <artifactId>jta</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
 </dependencies>
</dependencyManagement>

하위 POM:
<project>
 ...
 <dependencies>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-annotations</artifactId>
  </dependency>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate</artifactId>
  </dependency>
 </dependencies>
 ...
</project>

한 항목 이상 이 특정한 의존 에 의존한다 면 dependency Management 에서 이 의존 도 를 표시 할 수 있 습 니 다.부모 POM 은 하나의 버 전과 한 그룹의 배제 설정 을 포함 하고 있 으 며, 모든 하위 POM 은 groupId 와 artifactId 를 사용 하여 이 의존 도 를 참조 해 야 합 니 다.dependency Management 에 의존 하면 하위 항목 은 버 전과 설정 을 무시 할 수 있 습 니 다.
2. 버 전 중복 복구
 같은 버 전 을 공유 하 는 의존 도 있다.이러한 상황 은 보통 어떤 프로젝트 의 발표 버 전에 여러 개의 밀접 한 관 계 를 가 진 구성 요소 가 포함 되 어 있 기 때문이다.예 를 들 어 hibenate - annotations 와 hibenatecomons 에 의존 하 는 것 을 보 세 요. -
annotations, 두 가지 버 전 은 모두 3.3.0. ga 이 며, 우 리 는 이 두 가지 의존 버 전이 함께 앞으로 만 바 뀔 것 이 라 고 예상 할 수 있 습 니 다.hibenate - annotations 와 hibenate - comons - annotations 는 모두 JBoss 가 발표 한 같은 프로젝트 의 구성 요소 로 새로운 버 전이 발표 되면 두 의존 도가 달라 집 니 다.
부모 POM:
<project>
 ...
 <properties>
  <hibernate.annotations.version>3.3.0.ga</hibernate.annotations.version>
 </properties>
 <dependencyManagement>
  ...
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-annotations</artifactId>
   <version>${hibernate.annotations.version}</version>
  </dependency>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-commons-annotations</artifactId>
   <version>${hibernate.annotations.version}</version>
  </dependency>
  ...
 </dependencyManagement>
 ...
</project>

3. 형제 모듈 의존 과 형제 모듈 버 전의 중복 (상기 1 과 2 로 분류 가능)
4. 최적화 플러그 인
 최상 위 POM 에서 dependency Management 세 션 관리 의존 도 를 사용 합 니 다.

좋은 웹페이지 즐겨찾기