1、setting.xml

  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
  5. http://maven.apache.org/xsd/settings-1.0.0.xsd">
  6. <pluginGroups/>
  7. <proxies/>
  8. <servers/>
  9. <!-- maven自动下载的jar包,会存放到该目录下 -->
  10. <localRepository>D:\JavaFile\apache-maven-3.6.3\projectJarLib</localRepository>
  11. <!--<mirrors>
  12. &lt;!&ndash;<mirror>
  13. <id>alimaven</id>
  14. <mirrorOf>central</mirrorOf>
  15. <name>aliyun maven</name>
  16. <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
  17. </mirror>&ndash;&gt;
  18. <mirror>
  19. <id>central</id>
  20. <name>Maven Repository Switchboard</name>
  21. <url>http://repo1.maven.org/maven2/</url>
  22. <mirrorOf>central</mirrorOf>
  23. </mirror>
  24. <mirror>
  25. <id>repo2</id>
  26. <mirrorOf>central</mirrorOf>
  27. <name>Human Readable Name for this Mirror.</name>
  28. <url>http://repo2.maven.org/maven2/</url>
  29. </mirror>
  30. <mirror>
  31. <id>ibiblio</id>
  32. <mirrorOf>central</mirrorOf>
  33. <name>Human Readable Name for this Mirror.</name>
  34. <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
  35. </mirror>
  36. <mirror>
  37. <id>jboss-public-repository-group</id>
  38. <mirrorOf>central</mirrorOf>
  39. <name>JBoss Public Repository Group</name>
  40. <url>http://repository.jboss.org/nexus/content/groups/public</url>
  41. </mirror>
  42. <mirror>
  43. <id>google-maven-central</id>
  44. <name>Google Maven Central</name>
  45. <url>https://maven-central.storage.googleapis.com</url>
  46. <mirrorOf>central</mirrorOf>
  47. </mirror>
  48. &lt;!&ndash; 中央仓库在中国的镜像 &ndash;&gt;
  49. <mirror>
  50. <id>maven.net.cn</id>
  51. <name>oneof the central mirrors in china</name>
  52. <url>http://maven.net.cn/content/groups/public/</url>
  53. <mirrorOf>central</mirrorOf>
  54. </mirror>
  55. &lt;!&ndash; cloudera &ndash;&gt;
  56. <mirror>
  57. <id>cloudera-repos</id>
  58. <name>Cloudera Repos</name>
  59. <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
  60. <mirrorOf>central</mirrorOf>
  61. </mirror>
  62. &lt;!&ndash; aliyun &ndash;&gt;
  63. <mirror>
  64. <id>alimaven</id>
  65. <name>aliyun maven</name>
  66. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  67. <mirrorOf>central</mirrorOf>
  68. </mirror>
  69. </mirrors>-->
  70. <profiles>
  71. <profile>
  72. <!-- id必须唯一 -->
  73. <id>alimaven</id>
  74. <repositories>
  75. <repository>
  76. <!-- id必须唯一 -->
  77. <id>alimaven_1</id>
  78. <!-- 仓库的url地址 -->
  79. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  80. <releases>
  81. <enabled>true</enabled>
  82. </releases>
  83. <snapshots>
  84. <enabled>true</enabled>
  85. <updatePolicy>always</updatePolicy>
  86. </snapshots>
  87. </repository>
  88. </repositories>
  89. </profile>
  90. <profile>
  91. <!-- id必须唯一 -->
  92. <id>myRepository2</id>
  93. <repositories>
  94. <repository>
  95. <!-- id必须唯一 -->
  96. <id>myRepository2_1</id>
  97. <!-- 仓库的url地址 -->
  98. <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
  99. <releases>
  100. <enabled>true</enabled>
  101. </releases>
  102. <snapshots>
  103. <enabled>true</enabled>
  104. <updatePolicy>always</updatePolicy>
  105. </snapshots>
  106. </repository>
  107. </repositories>
  108. </profile>
  109. <profile>
  110. <!-- id必须唯一 -->
  111. <id>google-maven</id>
  112. <repositories>
  113. <repository>
  114. <!-- id必须唯一 -->
  115. <id>google-maven_1</id>
  116. <!-- 仓库的url地址 -->
  117. <url>https://maven-central.storage.googleapis.com</url>
  118. <releases>
  119. <enabled>true</enabled>
  120. </releases>
  121. <snapshots>
  122. <enabled>true</enabled>
  123. <updatePolicy>always</updatePolicy>
  124. </snapshots>
  125. </repository>
  126. </repositories>
  127. </profile>
  128. <profile>
  129. <!-- id必须唯一 -->
  130. <id>cloudera-repos</id>
  131. <repositories>
  132. <repository>
  133. <!-- id必须唯一 -->
  134. <id>cloudera-repos_1</id>
  135. <!-- 仓库的url地址 -->
  136. <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
  137. <releases>
  138. <enabled>true</enabled>
  139. </releases>
  140. <snapshots>
  141. <enabled>true</enabled>
  142. <updatePolicy>always</updatePolicy>
  143. </snapshots>
  144. </repository>
  145. </repositories>
  146. </profile>
  147. <profile>
  148. <!-- id必须唯一 -->
  149. <id>maven.net.cn</id>
  150. <repositories>
  151. <repository>
  152. <!-- id必须唯一 -->
  153. <id>maven.net.cn_1</id>
  154. <!-- 仓库的url地址 -->
  155. <url>http://maven.net.cn/content/groups/public/</url>
  156. <releases>
  157. <enabled>true</enabled>
  158. </releases>
  159. <snapshots>
  160. <enabled>true</enabled>
  161. <updatePolicy>always</updatePolicy>
  162. </snapshots>
  163. </repository>
  164. </repositories>
  165. </profile>
  166. <profile>
  167. <!-- id必须唯一 -->
  168. <id>jboss-public-repository-group</id>
  169. <repositories>
  170. <repository>
  171. <!-- id必须唯一 -->
  172. <id>jboss-public-repository-group_1</id>
  173. <!-- 仓库的url地址 -->
  174. <url>http://repository.jboss.org/nexus/content/groups/public</url>
  175. <releases>
  176. <enabled>true</enabled>
  177. </releases>
  178. <snapshots>
  179. <enabled>true</enabled>
  180. <updatePolicy>always</updatePolicy>
  181. </snapshots>
  182. </repository>
  183. </repositories>
  184. </profile>
  185. <profile>
  186. <!-- id必须唯一 -->
  187. <id>ibiblio</id>
  188. <repositories>
  189. <repository>
  190. <!-- id必须唯一 -->
  191. <id>ibiblio_1</id>
  192. <!-- 仓库的url地址 -->
  193. <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
  194. <releases>
  195. <enabled>true</enabled>
  196. </releases>
  197. <snapshots>
  198. <enabled>true</enabled>
  199. <updatePolicy>always</updatePolicy>
  200. </snapshots>
  201. </repository>
  202. </repositories>
  203. </profile>
  204. <profile>
  205. <!-- id必须唯一 -->
  206. <id>central</id>
  207. <repositories>
  208. <repository>
  209. <id>central_1</id>
  210. <!-- id必须唯一 -->
  211. <!-- 仓库的url地址 -->
  212. <url>http://repo1.maven.org/maven2/</url>
  213. <releases>
  214. <enabled>true</enabled>
  215. </releases>
  216. <snapshots>
  217. <enabled>true</enabled>
  218. <updatePolicy>always</updatePolicy>
  219. </snapshots>
  220. </repository>
  221. </repositories>
  222. </profile>
  223. </profiles>
  224. <!-- 添加使用 -->
  225. <activeProfiles>
  226. <activeProfile>google-maven</activeProfile>
  227. <activeProfile>myRepository2</activeProfile>
  228. <activeProfile>cloudera-repos</activeProfile>
  229. <activeProfile>alimaven</activeProfile>
  230. <activeProfile>maven.net.cn</activeProfile>
  231. <activeProfile>jboss-public-repository-group</activeProfile>
  232. <activeProfile>ibiblio</activeProfile>
  233. <activeProfile>central</activeProfile>
  234. </activeProfiles>
  235. </settings>

2、pom.xml

除了在设置里面修改,也可以在pom里面设置多个仓库

  1. <pluginRepositories>
  2. <pluginRepository>
  3. <id>scala-tools.org</id>
  4. <name>Scala-tools Maven3 Repository</name>
  5. <url>http://scala-tools.org/repo-releases</url>
  6. </pluginRepository>
  7. <pluginRepository>
  8. <id>cloudera-repos</id>
  9. <name>Cloudera Repos</name>
  10. <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
  11. </pluginRepository>
  12. <pluginRepository>
  13. <id>alimaven</id>
  14. <name>aliyun maven</name>
  15. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  16. </pluginRepository>
  17. </pluginRepositories>

3、效果

完成后可在IDEA maven栏中看到多个配置的仓库地址
image.png