自定义国内maven镜像包设置settings.xml
生活随笔
收集整理的這篇文章主要介紹了
自定义国内maven镜像包设置settings.xml
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
?
直接復制以下代碼創建一個名為settings.xml的文件,放到C:\Users\Administrator\.m2下即可
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--><!--| This is the configuration file for Maven. It can be specified at two levels:|| 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in $HOME/.m2/settings.xml.|| NOTE: This location can be overridden with the system property:|| -Dorg.apache.maven.user-settings=/path/to/user/settings.xml|| 2. Global Level. This settings.xml file provides configuration for all maven| users on a machine (assuming they're all using the same maven| installation). It's normally provided in | ${maven.home}/conf/settings.xml.|| NOTE: This location can be overridden with the system property:|| -Dorg.apache.maven.global-settings=/path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||-->
<settings><!--當插件的組織Id(groupId)沒有顯式提供時,供搜尋插件組織Id(groupId)的列表。該元素包含一個pluginGroup元素列表,每個子元素包含了一個組織Id(groupId)。當我們使用某個插件,并且沒有在命令行為其提供組織Id(groupId)的時候,Maven就會使用該列表。默認情況下該列表包含了org.apache.maven.plugins。--> <pluginGroups><!--plugin的組織Id(groupId) --> <pluginGroup>org.mortbay.jetty</pluginGroup></pluginGroups><!--本地倉庫。該值表示構建系統本地倉庫的路徑。其默認值為~/.m2/repository。 --> <localRepository>C:/Users/Administrator/.m2/repository</localRepository><!--Maven是否需要和用戶交互以獲得輸入。如果Maven需要和用戶交互以獲得輸入,則設置成true,反之則應為false。默認為true。--> <interactiveMode>true</interactiveMode><!--Maven是否需要使用plugin-registry.xml文件來管理插件版本。如果需要讓Maven使用文件~/.m2/plugin-registry.xml來管理插件版本,則設為true。默認為false。--> <usePluginRegistry>false</usePluginRegistry><!--表示Maven是否需要在離線模式下運行。如果構建系統需要在離線模式下運行,則為true,默認為false。當由于網絡設置原因或者安全因素,構建服務器不能連接遠程倉庫的時候,該配置就十分有用。 --> <offline>false</offline><!-- localRepository| The path to the local repository maven will use to store artifacts.|| Default: ~/.m2/repository<localRepository>/path/to/local/repo</localRepository>--><!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: true<interactiveMode>true</interactiveMode>--><!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: false<offline>false</offline>--><!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--><!--用來配置不同的代理,多代理profiles 可以應對筆記本或移動設備的工作環境:通過簡單的設置profile id就可以很容易的更換整個代理配置。 --> <proxies><!--代理元素包含配置代理時需要的信息--> <!-- proxy| Specification for one proxy, to be used in connecting to the network.|<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net,some.host.com</nonProxyHosts></proxy><proxy> <id>myProxy</id> <active>true</active> <protocol>http</protocol> <username></username><password></password> <host>10.71.19.195</host> <port>3125</port> <nonProxyHosts>localhost:192.168.2.218</nonProxyHosts> </proxy> --> </proxies><!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--><!--配置服務端的一些設置。一些設置如安全證書不應該和pom.xml一起分發。這種類型的信息應該存在于構建服務器上的settings.xml文件中。--> <servers></servers><!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.| | It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository.|--><!--為倉庫列表配置的下載鏡像列表。 --> <mirrors><!--給定倉庫的下載鏡像。 --><mirror><!--該鏡像的唯一標識符。id用來區分不同的mirror元素。 --> <id>nexus-local</id><!--鏡像名稱 --><name>nexus-local</name><!--被鏡像的服務器的id。例如,如果我們要設置了一個Maven中央倉庫(http://repo1.maven.org/maven2)的鏡像,就需要將該元素設置成central。這必須和中央倉庫的id central完全一致。--> <mirrorOf>*</mirrorOf><!--該鏡像的URL。構建系統會優先考慮使用該URL,而非使用默認的服務器URL。 --> <url>http://192.168.2.172:8081/repository/maven-public/</url></mirror><!-- 阿里國內鏡像 --><mirror><id>aliyun-repository</id><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><mirrorOf>central</mirrorOf></mirror><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--></mirrors><!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact| repositories, plugin repositories, and free-form properties to be used as configuration| variables for plugins in the POM.||--><profiles><!--根據環境參數來調整的構件的配置--> <profile> <!--該配置的唯一標識符。 --> <id>nexus-local</id><!--自動觸發profile的條件邏輯。Activation是profile的開啟鑰匙。如POM中的profile一樣,profile的力量來自于它能夠在某些特定的環境中自動使用某些特定的值;這些環境通過activation元素指定。activation元素并不是激活profile的唯一方式。settings.xml文件中的activeProfile元素可以包含profile的id。profile也可以通過在命令行,使用-P標記和逗號分隔的列表來顯式的激活(如,-P test)。--> <activation><!--profile默認是否激活的標識--><activeByDefault>true</activeByDefault> <!--當匹配的jdk被檢測到,profile被激活。例如,1.4激活JDK1.4,1.4.0_2,而!1.4激活所有版本不是以1.4開頭的JDK。--> <jdk>1.5</jdk><!--當匹配的操作系統屬性被檢測到,profile被激活。os元素可以定義一些操作系統相關的屬性。--> </activation> <!--遠程倉庫列表,它是Maven用來填充構建系統本地倉庫所使用的一組遠程項目。 --> <repositories> <!--包含需要連接到遠程倉庫的信息 --><repository> <!--遠程倉庫唯一標識--> <id>nexus-public</id> <!--遠程倉庫名稱 --><name>Nexus Repository</name> <!--遠程倉庫URL,按protocol://hostname/path形式 --> <url>http://192.168.2.172:8081/repository/maven-public/</url> <!--如何處理遠程倉庫里發布版本的下載--> <releases> <!--true或者false表示該倉庫是否為下載某種類型構件(發布版,快照版)開啟。 --> <enabled>true</enabled> <!--該元素指定更新發生的頻率。Maven會比較本地POM和遠程POM的時間戳。這里的選項是:always(一直),daily(默認,每日),interval:X(這里X是以分鐘為單位的時間間隔),或者never(從不)。 --> <updatePolicy>always</updatePolicy> <!--當Maven驗證構件校驗文件失敗時該怎么做-ignore(忽略),fail(失敗),或者warn(警告)。--><checksumPolicy>warn</checksumPolicy> </releases> <!--如何處理遠程倉庫里快照版本的下載。有了releases和snapshots這兩組配置,POM就可以在每個單獨的倉庫中,為每種類型的構件采取不同的策略。例如,可能有人會決定只為開發目的開啟對快照版本下載的支持。參見repositories/repository/releases元素--><snapshots> <!--true或者false表示該倉庫是否為下載某種類型構件(發布版,快照版)開啟。 --> <enabled>true</enabled><!--該元素指定更新發生的頻率。Maven會比較本地POM和遠程POM的時間戳。這里的選項是:always(一直),daily(默認,每日),interval:X(這里X是以分鐘為單位的時間間隔),或者never(從不)。 --> <updatePolicy>always</updatePolicy> <!--當Maven驗證構件校驗文件失敗時該怎么做-ignore(忽略),fail(失敗),或者warn(警告)。--><checksumPolicy>warn</checksumPolicy> </snapshots> <!--用于定位和排序構件的倉庫布局類型-可以是default(默認)或者legacy(遺留)。Maven 2為其倉庫提供了一個默認的布局;然而,Maven 1.x有一種不同的布局。我們可以使用該元素指定布局是default(默認)還是legacy(遺留)。 --> <layout>default</layout> </repository> </repositories> <!--發現插件的遠程倉庫列表。倉庫是兩種主要構件的家。第一種構件被用作其它構件的依賴。這是中央倉庫中存儲的大部分構件類型。另外一種構件類型是插件。Maven插件是一種特殊類型的構件。由于這個原因,插件倉庫獨立于其它倉庫。pluginRepositories元素的結構和repositories元素的結構類似。每個pluginRepository元素指定一個Maven可以用來尋找新插件的遠程地址。--><pluginRepositories> <!--包含需要連接到遠程插件倉庫的信息.參見profiles/profile/repositories/repository元素的說明--><pluginRepository> <!--遠程倉庫唯一標識--> <id>nexus-plugins</id> <!--遠程倉庫名稱 --><name>Nexus Plugins Repository</name> <!--遠程倉庫URL,按protocol://hostname/path形式 --> <url>http://192.168.2.172:8081/repository/maven-public/</url> <!--如何處理遠程倉庫里發布版本的下載--> <releases> <enabled>true</enabled> <!--該元素指定更新發生的頻率。Maven會比較本地POM和遠程POM的時間戳。這里的選項是:always(一直),daily(默認,每日),interval:X(這里X是以分鐘為單位的時間間隔),或者never(從不)。 --> <updatePolicy>always</updatePolicy> <!--當Maven驗證構件校驗文件失敗時該怎么做-ignore(忽略),fail(失敗),或者warn(警告)。--><checksumPolicy>ignore</checksumPolicy> </releases> <!--如何處理遠程倉庫里發布版本的下載--> <snapshots> <enabled>true</enabled><!--該元素指定更新發生的頻率。Maven會比較本地POM和遠程POM的時間戳。這里的選項是:always(一直),daily(默認,每日),interval:X(這里X是以分鐘為單位的時間間隔),或者never(從不)。 --> <updatePolicy>always</updatePolicy> <!--當Maven驗證構件校驗文件失敗時該怎么做-ignore(忽略),fail(失敗),或者warn(警告)。--><checksumPolicy>ignore</checksumPolicy> </snapshots> </pluginRepository> </pluginRepositories> </profile><profile><id>aliyun-repository</id><repositories><repository><id>aliyun</id><url>http://maven.aliyun.com/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories></profile></profiles> <!--手動激活profiles的列表,按照profile被應用的順序定義activeProfile。 該元素包含了一組activeProfile元素,每個activeProfile都含有一個profile id。任何在activeProfile中定義的profile id,不論環境設置如何,其對應的profile都會被激活。如果沒有匹配的profile,則什么都不會發生。例如,env-test是一個activeProfile,則在pom.xml(或者profile.xml)中對應id的profile會被激活。如果運行過程中找不到這樣一個profile,Maven則會像往常一樣運行。 --><activeProfiles> <activeProfile>nexus-local</activeProfile><activeProfile>aliyun-repository</activeProfile></activeProfiles> <!-- activeProfiles| List of profiles that are active for all builds.|<activeProfiles><activeProfile>alwaysActiveProfile</activeProfile><activeProfile>anotherAlwaysActiveProfile</activeProfile></activeProfiles>-->
</settings>
總結
以上是生活随笔為你收集整理的自定义国内maven镜像包设置settings.xml的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【只需三步】用IDEA打开一个新的jsp
- 下一篇: 【全网之最】用JavaScript写一个