maven 项目,pom中的repositories 要充分使用

aven 项目,pom中的repositories 要充分使用

1. <repositories>

<?xml version="1.0" encoding="UTF-8"?>
<project......

.......

<!-- 设定除中央仓库(repo1.maven.org/maven2/)外的其他仓库,按设定顺序进行查找. -->
<repositories>
   <repository>
    <id>nexus</id>
    <name>Team Nexus Repository</name>
    <url>http://localhost:8081/nexus/content/groups/public</url>
   </repository>

   <repository>
    <id>offical</id>
    <name>Maven Official Repository</name>
    <url>http://repo1.maven.org/maven2</url>
    <snapshots>
     <enabled>false</enabled>
    </snapshots>
   </repository>

......

</repositories>

可以在单个pom 文件中设置当前工程使用的repository.这样的设置

2. <dependencyManagement> 预定义依赖项的version,scope与exclusions,子项目中只需定义groupId 和 artifactId 即可.实现的目的是:可以把一些特殊的依赖在父项目中统一定义好,子项目中只需要知道用哪些就行了,而不用关心版本号,排除哪些依赖、使用范围是什么。


<dependencyManagement>
   <dependencies>

......

   </dependencies>

</dependencyManagement>

3.    <pluginManagement> 把插件使用的版本等信息在父工程中定义好,子工程中使用即可。

<!-- 插件配置 -->
<build>
   <pluginManagement>
    <plugins>

......

/

Maven 的设计思想,是慢慢才领会的。许多的内容平时都没有用起来。

需要多了解下。

猜你喜欢

转载自zhangzuanqian.iteye.com/blog/1808174