..._第一个nexus-xu要和下面的mirror中的id一致,代表拉取是也需要进行身份校验">
当前位置:   article > 正文

maven仓库的settings配置_第一个nexus-xu要和下面的mirror中的id一致,代表拉取是也需要进行身份校验

第一个nexus-xu要和下面的mirror中的id一致,代表拉取是也需要进行身份校验

settings配置分为两种情况,一种是没有maven私服直接连接阿里云的远程仓库的,另一种是有有maven私服连接公司内部私服的。两种情况的settings配置不一样。我们分开来写。

1、没有maven私服直接连接阿里云远程镜像仓库的,这种情况只需要配置远程镜像仓库和本地仓库位置即可。

如下所示,

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing,
  12. software distributed under the License is distributed on an
  13. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. KIND, either express or implied. See the License for the
  15. specific language governing permissions and limitations
  16. under the License.
  17. -->
  18. <!--
  19. | This is the configuration file for Maven. It can be specified at two levels:
  20. |
  21. | 1. User Level. This settings.xml file provides configuration for a single user,
  22. | and is normally provided in ${user.home}/.m2/settings.xml.
  23. |
  24. | NOTE: This location can be overridden with the CLI option:
  25. |
  26. | -s /path/to/user/settings.xml
  27. |
  28. | 2. Global Level. This settings.xml file provides configuration for all Maven
  29. | users on a machine (assuming they're all using the same Maven
  30. | installation). It's normally provided in
  31. | ${maven.home}/conf/settings.xml.
  32. |
  33. | NOTE: This location can be overridden with the CLI option:
  34. |
  35. | -gs /path/to/global/settings.xml
  36. |
  37. | The sections in this sample file are intended to give you a running start at
  38. | getting the most out of your Maven installation. Where appropriate, the default
  39. | values (values used when the setting is not specified) are provided.
  40. |
  41. |-->
  42. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  43. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  44. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  45. <!-- localRepository
  46. | The path to the local repository maven will use to store artifacts.
  47. |
  48. | Default: ~/.m2/repository-->
  49. <localRepository>E:/local/repository</localRepository>
  50. <!-- interactiveMode
  51. | This will determine whether maven prompts you when it needs input. If set to false,
  52. | maven will use a sensible default value, perhaps based on some other setting, for
  53. | the parameter in question.
  54. |
  55. | Default: true
  56. <interactiveMode>true</interactiveMode>
  57. -->
  58. <!-- offline
  59. | Determines whether maven should attempt to connect to the network when executing a build.
  60. | This will have an effect on artifact downloads, artifact deployment, and others.
  61. |
  62. | Default: false
  63. <offline>false</offline>
  64. -->
  65. <!-- pluginGroups
  66. | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
  67. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
  68. | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
  69. |-->
  70. <pluginGroups>
  71. <!-- pluginGroup
  72. | Specifies a further group identifier to use for plugin lookup.
  73. <pluginGroup>com.your.plugins</pluginGroup>
  74. -->
  75. </pluginGroups>
  76. <!-- proxies
  77. | This is a list of proxies which can be used on this machine to connect to the network.
  78. | Unless otherwise specified (by system property or command-line switch), the first proxy
  79. | specification in this list marked as active will be used.
  80. |-->
  81. <proxies>
  82. <!-- proxy
  83. | Specification for one proxy, to be used in connecting to the network.
  84. |
  85. <proxy>
  86. <id>optional</id>
  87. <active>true</active>
  88. <protocol>http</protocol>
  89. <username>proxyuser</username>
  90. <password>proxypass</password>
  91. <host>proxy.host.net</host>
  92. <port>80</port>
  93. <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
  94. </proxy>
  95. -->
  96. </proxies>
  97. <!-- servers
  98. | This is a list of authentication profiles, keyed by the server-id used within the system.
  99. | Authentication profiles can be used whenever maven must make a connection to a remote server.
  100. |-->
  101. <servers>
  102. <!-- server
  103. | Specifies the authentication information to use when connecting to a particular server, identified by
  104. | a unique name within the system (referred to by the 'id' attribute below).
  105. |
  106. | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
  107. | used together.
  108. |
  109. <server>
  110. <id>deploymentRepo</id>
  111. <username>repouser</username>
  112. <password>repopwd</password>
  113. </server>
  114. -->
  115. <!-- Another sample, using keys to authenticate.
  116. <server>
  117. <id>siteServer</id>
  118. <privateKey>/path/to/private/key</privateKey>
  119. <passphrase>optional; leave empty if not used.</passphrase>
  120. </server>
  121. -->
  122. </servers>
  123. <!-- mirrors
  124. | This is a list of mirrors to be used in downloading artifacts from remote repositories.
  125. |
  126. | It works like this: a POM may declare a repository to use in resolving certain artifacts.
  127. | However, this repository may have problems with heavy traffic at times, so people have mirrored
  128. | it to several places.
  129. |
  130. | That repository definition will have a unique id, so we can create a mirror reference for that
  131. | repository, to be used as an alternate download site. The mirror site will be the preferred
  132. | server for that repository.
  133. |-->
  134. <mirrors>
  135. <!-- mirror
  136. | Specifies a repository mirror site to use instead of a given repository. The repository that
  137. | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
  138. | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
  139. |
  140. <mirror>
  141. <id>mirrorId</id>
  142. <mirrorOf>repositoryId</mirrorOf>
  143. <name>Human Readable Name for this Mirror.</name>
  144. <url>http://my.repository.com/repo/path</url>
  145. </mirror>
  146. -->
  147. <mirror>
  148. <id>alimaven</id>
  149. <name>aliyun maven</name>
  150. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  151. <!--mirrorOf>central</mirrorOf-->
  152. <mirrorOf>*</mirrorOf>
  153. </mirror>
  154. </mirrors>
  155. <!-- profiles
  156. | This is a list of profiles which can be activated in a variety of ways, and which can modify
  157. | the build process. Profiles provided in the settings.xml are intended to provide local machine-
  158. | specific paths and repository locations which allow the build to work in the local environment.
  159. |
  160. | For example, if you have an integration testing plugin - like cactus - that needs to know where
  161. | your Tomcat instance is installed, you can provide a variable here such that the variable is
  162. | dereferenced during the build process to configure the cactus plugin.
  163. |
  164. | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
  165. | section of this document (settings.xml) - will be discussed later. Another way essentially
  166. | relies on the detection of a system property, either matching a particular value for the property,
  167. | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
  168. | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
  169. | Finally, the list of active profiles can be specified directly from the command line.
  170. |
  171. | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
  172. | repositories, plugin repositories, and free-form properties to be used as configuration
  173. | variables for plugins in the POM.
  174. |
  175. |-->
  176. <profiles>
  177. <profile>
  178. <id>jdk-1.8</id>
  179. <activation>
  180. <activeByDefault>true</activeByDefault>
  181. <jdk>1.8</jdk>
  182. </activation>
  183. <properties>
  184. <maven.compiler.source>1.8</maven.compiler.source>
  185. <maven.compiler.target>1.8</maven.compiler.target>
  186. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
  187. </properties>
  188. </profile>
  189. <!-- profile
  190. | Specifies a set of introductions to the build process, to be activated using one or more of the
  191. | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
  192. | or the command line, profiles have to have an ID that is unique.
  193. |
  194. | An encouraged best practice for profile identification is to use a consistent naming convention
  195. | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
  196. | This will make it more intuitive to understand what the set of introduced profiles is attempting
  197. | to accomplish, particularly when you only have a list of profile id's for debug.
  198. |
  199. | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
  200. <profile>
  201. <id>jdk-1.4</id>
  202. <activation>
  203. <jdk>1.4</jdk>
  204. </activation>
  205. <repositories>
  206. <repository>
  207. <id>jdk14</id>
  208. <name>Repository for JDK 1.4 builds</name>
  209. <url>http://www.myhost.com/maven/jdk14</url>
  210. <layout>default</layout>
  211. <snapshotPolicy>always</snapshotPolicy>
  212. </repository>
  213. </repositories>
  214. </profile>
  215. -->
  216. <!--
  217. | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
  218. | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
  219. | might hypothetically look like:
  220. |
  221. | ...
  222. | <plugin>
  223. | <groupId>org.myco.myplugins</groupId>
  224. | <artifactId>myplugin</artifactId>
  225. |
  226. | <configuration>
  227. | <tomcatLocation>${tomcatPath}</tomcatLocation>
  228. | </configuration>
  229. | </plugin>
  230. | ...
  231. |
  232. | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
  233. | anything, you could just leave off the <value/> inside the activation-property.
  234. |
  235. <profile>
  236. <id>env-dev</id>
  237. <activation>
  238. <property>
  239. <name>target-env</name>
  240. <value>dev</value>
  241. </property>
  242. </activation>
  243. <properties>
  244. <tomcatPath>/path/to/tomcat/instance</tomcatPath>
  245. </properties>
  246. </profile>
  247. -->
  248. </profiles>
  249. <!-- activeProfiles
  250. | List of profiles that are active for all builds.
  251. |
  252. <activeProfiles>
  253. <activeProfile>alwaysActiveProfile</activeProfile>
  254. <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  255. </activeProfiles>
  256. -->
  257. </settings>

2、公司内部有maven私服的,除了要配置本地仓库外,镜像仓库配置成公司内部私服的仓库,还要配置私服仓库的id和账户密码。如下所示

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  5. <localRepository>E:/local/repository1</localRepository>
  6. <pluginGroups></pluginGroups>
  7. <proxies></proxies>
  8. <servers>
  9. <server>
  10. <id>nexus</id> <!--第一个nexus要和下面的mirror中的id一致,代表拉取是也需要进行身份校验-->
  11. <username>admin</username>
  12. <password>admin123</password>
  13. </server>
  14. <server> <!--稳定版仓库,jar上传时候进行的验证,id对应的是pom中id属性的值-->
  15. <id>release</id>
  16. <username>admin</username>
  17. <password>admin123</password>
  18. </server>
  19. <server> <!--不稳定版本仓库(jar包后缀为SNAPSHOT的),jar上传时候进行的验证,id对应的是pom中id属性的值-->
  20. <id>snapshots</id>
  21. <username>admin</username>
  22. <password>admin123</password>
  23. </server>
  24. </servers>
  25. <mirrors>
  26. <mirror>
  27. <id>nexus</id>
  28. <name>internal nexus repository</name>
  29. <url>http://192.168.1.156:8888/repository/maven-public/</url><!--镜像采用默认的组的地址-->
  30. <mirrorOf>*</mirrorOf>
  31. </mirror>
  32. </mirrors>
  33. <profiles>
  34. <profile>
  35. <id>jdk-1.8</id>
  36. <activation>
  37. <activeByDefault>true</activeByDefault>
  38. <jdk>1.8</jdk>
  39. </activation>
  40. <properties>
  41. <maven.compiler.source>1.8</maven.compiler.source>
  42. <maven.compiler.target>1.8</maven.compiler.target>
  43. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
  44. </properties>
  45. </profile>
  46. <profile>
  47. <id>nexus-pro</id>
  48. <repositories> <!-- 远程仓库列表 -->
  49. <repository>
  50. <id>nexus-xu</id>
  51. <name>Nexus Central</name>
  52. <url>http://192.168.1.156:8888/repository/maven-public/</url> <!-- 虚拟的URL形式,指向镜像的URL-->
  53. <layout>default</layout>
  54. <releases>
  55. <enabled>true</enabled> <!-- 表示可以从这个仓库下载releases版本的构件-->
  56. </releases>
  57. <snapshots>
  58. <enabled>true</enabled> <!-- 表示可以从这个仓库下载snapshot版本的构件 -->
  59. </snapshots>
  60. </repository>
  61. </repositories>
  62. <!-- 插件仓库列表 -->
  63. <pluginRepositories>
  64. <pluginRepository>
  65. <id>nexus-xu</id>
  66. <name>Nexus Central</name>
  67. <url>http://192.168.1.156:8888/repository/maven-public/</url>
  68. <layout>default</layout>
  69. <snapshots>
  70. <enabled>true</enabled>
  71. </snapshots>
  72. <releases>
  73. <enabled>true</enabled>
  74. </releases>
  75. </pluginRepository>
  76. </pluginRepositories>
  77. </profile>
  78. </profiles>
  79. <activeProfiles>
  80. <!--需要激活 <profile>中的ID才生效-->
  81. <activeProfile>nexus-pro</activeProfile>
  82. <!--<activeProfile>jdk-1.8</activeProfile>-->
  83. </activeProfiles>
  84. </settings>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/87483
推荐阅读
相关标签
  

闽ICP备14008679号