1. 程式人生 > >maven的setting.xml檔案配置詳情

maven的setting.xml檔案配置詳情

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<!--本地倉庫的路徑,預設值為${user.home}/.m2/repository-->
<localRepository>D:\\Maven\\MavenRepository\\MavenRepository</localRepository>

<!--當外掛的組織id(groupId)沒有顯示提供時,供搜尋外掛組織Id(groupId)的列表,該元素包含一個plugGroup元素列表,每個子元素包含一個組織Id(groupId).並且沒有在命令列為其提供組織Id(groupId)的時候,Maven就會使用該列表.預設情況下給列表包含了org.apach.maven.plugins和org.codehaus.mojo-->

<pluginGroups>
</pluginGroups>

<!--用來配置不同的代理,多代理profiles可以對應筆記本或移動裝置的工作環境:通過簡單的設定profile id就可以很容易的更換整個代理配置-->

<proxies>

</proxies>

<!-- 配 上傳的賬號和密碼 -->

<!--配置服務端的一些設定,一些設定如安全證書不應該和pom.xml一起分發.這種型別的資訊應該存在與構建伺服器的setting.xml檔案中-->

<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<!-- 配私服映象 , 使用所有要下載的包也通過私服下載-->
<mirrors>

<mirror>

<!---該映象的唯一識別符號,id用來區分不同的mirror元素->

<id>nexus</id>

<!--被映象的伺服器id.例如,如果我們設定了一個maven中央倉庫()的映象,就需要將該元素設定成central.這必須與中央倉庫的id central完全一致.-->

<mirrorOf>*</mirrorOf>
<!-- <url>http://218.196.14.220:8081/nexus/content/groups/public</url> -->
<!-- <url>http://localhost:8081/nexus/content/groups/public</url> 
<url>http://192.168.15.100:8081/nexus/content/groups/public/</url>
<url>http://218.196.14.220:8081/nexus/content/groups/public/</url>-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>

<!--根據環境引數來調整構建配置的列表,setting.xml中的profile元素是pom.xml中profile元素的裁剪版本.它包含了id,activation,repositories,pluginrepositories和properties元素.這裡的profile元素只包含這五個元素是因為這隻關心構建系統這個整體(這正是setting.xml檔案的角色定位),而非單獨的專案物件模型設定.如果一個settings中的profile被啟用,它的值會覆蓋任何其他定義在pom中或者profile.xml中的帶有相同id的profile.-->
<profiles>
<profile>
<id>central</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>


<profile>
<id>jdk1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>

</profiles>

<!--手動啟用profile的列表,按照profile被應用的順序定義activeProfile.該元素包含了一組activePrifile元素,每個activeProfile都包含一個profile id.任何在activeProfile中定義的profile id,不論環境設定如何,其對應profile都會被啟用,如果沒有匹配的profile,則什麼都不會發生.例如,env-test是一個activeProfile,則在pom.xml(或者在profile.xml)中的id的profile會被啟用.如果執行過程中找不到這樣一個profile,Maven則會像往常一樣執行.-->

<activeProfiles>
<activeProfile>central</activeProfile>
</activeProfiles>
</settings>