maven pom文件标签含义


1、dependency里面的scope

dependency里面的classifier

dependency里面的type

dependency里面的systemPath

dependency里面的optional:

dependency里面的exclusions:

 

2、dependency里面的version

maven的pom.xml有些依赖为什么可以不写版本号。因为他的 <parent> 父级依赖已经定义了版本,子项目自己的groupId和version可以从父项目继承。

 

3、repositories 和 pluginRepository

pom.xml中repositories标签的作用是: 用来配置maven项目的远程仓库。示例如下:
    <repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus Repository</name>
            <url>远程仓库地址</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>  <!--snapshots默认是关闭的,需要开启  -->
            </snapshots>
        </repository>
    </repositories>

按照上面配置是实现了配置maven项目的远程仓库,但是,这样的配置,如果我们创建一个项目,就需要配置一次,很麻烦。可以将上面的远程仓库配置在maven的setting.xml里面.这样就可以实现只配置一次
 

pom.xml中pluginRepository标签的作用是: 用来配置maven插件的远程仓库。示例如下:
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>远程仓库地址</url>
        </pluginRepository>
    </pluginRepositories>

 

4、import

  import只在dependencyManagement元素下才有效果,作用是将目标POM中的dependencyManagement配置导入并合并到当前POM的dependencyManagement元素中,如下就是讲account-aggregator中的dependencyManagement配置导入并合并到当前POM中。

<dependencyManagement>
      <dependencies>
        <dependency>
            <groupId>com.youzhibing.account</groupId>
              <artifactId>account-aggregator</artifactId>
              <version>1.0.0-SNAPSHOT</version>
            <type>pom</type>
              <scope>import</scope>
        </dependency>
      </dependencies>
  </dependencyManagement>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM