maven小筆記

Maven小筆記

一、  可選依賴

<option>true/false</option>,是否向下傳遞。

二、  排除依賴

<exclusions>

<exclusion>

        依賴jar座標

</exclusion>

</exclusions>,排除繼承而來的依賴。

三、  依賴衝突

依賴衝突,即同一個pom.xml文件中,多個不同版本jar的依賴,最終引入最後配置的jar版本;亦或在子pom.xml文件中,重寫某個jar依賴,會覆蓋父jar依賴。

四、  setting.xml配置解析

<mirrors>

<mirror>

<id>nexus</id>

<!-- *代表所有的jar都到url地址下載,也可以寫central -->

<mirrorOf>*</mirrorOf>

<url>私庫地址</url>

</mirror>

</mirrors>

------------------------------------分割線--------------------------------------------

<profiles>

       <profile>

            <id>nexus</id>

            <!—所有請求均通過鏡像 -->

            <repositories>

          <!--jar 依賴central,指定下載地址-->

                  <repository>

                       <id>central</id>

                       <url>http://central</url>

                       <!—releases正式版本 -->

                       <releases><enabled>true</enabled></releases>

                       <!—snapshots先行版本 -->

                       <snapshots><enabled>true</enabled></snapshots>

                  </repository>

            </repositories>

            <pluginRepositories>

                  <!—插件central,指定下載地址-->

                  <pluginRepository>

                       <id>central</id>

                       <url>http://central</url>

                       <releases><enabled>true</enabled></releases>

                       <snapshots><enabled>true</enabled></snapshots>

                  </pluginRepository>

            </pluginRepositories>

       </profile>

 </profiles>

------------------------------------分割線--------------------------------------------

<!—下載地址可以配置多個,這裏指定使用哪一個地址-->

<activeProfiles>

          <!--makethe profile active all the time -->

          <activeProfile>nexus</activeProfile>

</activeProfiles>

------------------------------------分割線--------------------------------------------

<!-- 設置發佈時的用戶名 -->

<servers>

 <server>

  <!--正式版本 -->

  <id> releases </id>

<username>admin</username>

<password>admin123</password>

</server>

<server>

<!—先行版本 -->

<id> snapshots </id>

<username>admin</username>

<password>admin123</password>

 </server>

</servers>

五、  pom.xml

部署構建到Nexus,包含Release和Snapshot

<distributionManagement>

<repository>

<id>releases</id>

  <name>InternalReleases</name>  <url>http://localhost:8000/nexus/content/repositories/releases/</url>

</repository>

<snapshotRepository>

       <id>snapshots</id>

       <name>Internal Snapshots</name>       <url>http://localhost:8000/nexus/content/repositories/snapshots/</url>

</snapshotRepository>

</distributionManagement>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章