zoukankan      html  css  js  c++  java
  • 3.1-1 dependencyManagement中的type为pom用法

     
    以第3章示例:spmia-chapter3-master中的子项目confsvr为例说明:
    其pom文件内容摘要如下:
     
      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.4.RELEASE</version>
      </parent>
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR5</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>
     
      <dependencies>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
     
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
      </dependencies>
     
    我们使用idea导入该工程,打开该子项目的pom.xml文件,然后右键中选择“show effective pom”,这会打开一个名为“configurationserver-effective-pom.xml”的窗口。
    上面的<scope>import</scope>表示将版本为Camden.SR5的依赖spring-cloud-dependencies所对应的pom文件信息导入进来。
    所以名为“configurationserver-effective-pom.xml”的窗口中的<dependencyManagement>元素会将pom.xml扩展开来,所以会有很多内容。
     
    我们对名为“configurationserver-effective-pom.xml”的窗口中的<dependencyManagement>元素下的内容和pom.xml中声明的两个依赖的最终版本号进行分析:
      <dependencies>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-config-server</artifactId>
          <version>1.2.2.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-config</artifactId>
          <version>1.2.2.RELEASE</version>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    就会发现 <dependencyManagement>不仅用于对子项目的依赖的版本管理,还用于对它自身所在的项目的依赖的版本管理。
     
  • 相关阅读:
    xml DTD中的ELEMENT和ATTLIST
    xml CDATA
    xml 及其语法
    java 多态的好处
    libusb-win32 在visual studio2008中成功编译回忆录
    【转帖】C# DllImport 系统调用使用详解 托管代码的介绍 EntryPoint的使用
    【转帖】.Net中C#的DllImport的用法
    .net 中的DllImport
    离线安装谷歌扩展
    排序算法哪家强?
  • 原文地址:https://www.cnblogs.com/mongotea/p/11973195.html
Copyright © 2011-2022 走看看