maven私服设置

[复制链接]
发表于 2025-9-18 19:32:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
使用Nexus作为 公司maven私服

可以使用docker快速安装一个
maven 私服setttings设置
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
  3.           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  5.   <!-- localRepository
  6.    | The path to the local repository maven will use to store artifacts.
  7.    |
  8.    | Default: ${user.home}/.m2/repository
  9.   <localRepository>/path/to/local/repo</localRepository>
  10.   -->
  11. <localRepository>D:\dev\mavenRepository</localRepository>
  12.   <!-- interactiveMode
  13.    | This will determine whether maven prompts you when it needs input. If set to false,
  14.    | maven will use a sensible default value, perhaps based on some other setting, for
  15.    | the parameter in question.
  16.    |
  17.    | Default: true
  18.   <interactiveMode>true</interactiveMode>
  19.   -->
  20.   <!-- offline
  21.    | Determines whether maven should attempt to connect to the network when executing a build.
  22.    | This will have an effect on artifact downloads, artifact deployment, and others.
  23.    |
  24.    | Default: false
  25.   <offline>false</offline>
  26.   -->
  27.   <!-- pluginGroups
  28.    | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
  29.    | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
  30.    | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
  31.    |-->
  32.   <pluginGroups>
  33.     <!-- pluginGroup
  34.      | Specifies a further group identifier to use for plugin lookup.
  35.     <pluginGroup>com.your.plugins</pluginGroup>
  36.     -->
  37.   </pluginGroups>
  38.   <!-- proxies
  39.    | This is a list of proxies which can be used on this machine to connect to the network.
  40.    | Unless otherwise specified (by system property or command-line switch), the first proxy
  41.    | specification in this list marked as active will be used.
  42.    |-->
  43.   <proxies>
  44.     <!-- proxy
  45.      | Specification for one proxy, to be used in connecting to the network.
  46.      |
  47.     <proxy>
  48.       <id>optional</id>
  49.       <active>true</active>
  50.       <protocol>http</protocol>
  51.       <username>proxyuser</username>
  52.       <password>proxypass</password>
  53.       <host>proxy.host.net</host>
  54.       <port>80</port>
  55.       <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
  56.     </proxy>
  57.     -->
  58.   </proxies>
  59. <!--新增仓库认证账号密码-->
  60. <servers>
  61.        
  62.         <server>
  63.         <id>nexus-releases</id>
  64.         <username>xxxx</username>
  65.         <password>xxx@xxx</password>
  66.     </server>
  67.     <server>
  68.         <id>nexus-snapshots</id>
  69.         <username>xxxx</username>
  70.         <password>xxx@xxx</password>
  71.     </server>
  72. </servers>
  73.   
  74.   <mirrors>
  75.    
  76.         <mirror>
  77.         <id>alimaven</id>
  78.         <name>aliyun maven</name>
  79.         <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  80.         <mirrorOf>central</mirrorOf>
  81.         </mirror>
  82.   </mirrors>
  83.   <!-- profiles
  84.    | This is a list of profiles which can be activated in a variety of ways, and which can modify
  85.    | the build process. Profiles provided in the settings.xml are intended to provide local machine-
  86.    | specific paths and repository locations which allow the build to work in the local environment.
  87.    |
  88.    | For example, if you have an integration testing plugin - like cactus - that needs to know where
  89.    | your Tomcat instance is installed, you can provide a variable here such that the variable is
  90.    | dereferenced during the build process to configure the cactus plugin.
  91.    |
  92.    | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
  93.    | section of this document (settings.xml) - will be discussed later. Another way essentially
  94.    | relies on the detection of a system property, either matching a particular value for the property,
  95.    | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
  96.    | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
  97.    | Finally, the list of active profiles can be specified directly from the command line.
  98.    |
  99.    | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
  100.    |       repositories, plugin repositories, and free-form properties to be used as configuration
  101.    |       variables for plugins in the POM.
  102.    |
  103.    |-->
  104. <!--新增私有仓库-->
  105. <profiles>
  106. <profile>
  107.   <id>nexus</id>
  108.   <repositories>
  109.     <repository>
  110.       <id>nexus-releases</id>
  111.       <url>http://nexus地址:端口/repository/maven-releases/</url>
  112.       <releases><enabled>true</enabled></releases>
  113.       <snapshots><enabled>false</enabled></snapshots>
  114.     </repository>
  115.     <repository>
  116.       <id>nexus-snapshot</id>
  117.       <url>http://1http://nexus地址:端口/repository/maven-snapshots/</url>
  118.       <releases><enabled>false</enabled></releases>
  119.       <snapshots><enabled>true</enabled></snapshots>
  120.     </repository>
  121.   </repositories>
  122.   <pluginRepositories>
  123.     <pluginRepository>
  124.       <id>nexus-release</id>
  125.       <url>http://http://nexus地址:端口/repository/maven-releases/</url>
  126.       <releases><enabled>true</enabled></releases>
  127.       <snapshots><enabled>false</enabled></snapshots>
  128.     </pluginRepository>
  129.     <pluginRepository>
  130.       <id>nexus-snapshot</id>
  131.       <url>http://http://nexus地址:端口/repository/maven-snapshots/</url>
  132.       <releases><enabled>false</enabled></releases>
  133.       <snapshots><enabled>true</enabled></snapshots>
  134.     </pluginRepository>
  135.   </pluginRepositories>
  136. </profile>
  137.   </profiles>
  138. <!-- 激活nexus profile -->
  139. <activeProfiles>
  140.   <activeProfile>nexus</activeProfile>
  141. </activeProfiles>
  142.   <!-- activeProfiles
  143.    | List of profiles that are active for all builds.
  144.    |
  145.   <activeProfiles>
  146.     <activeProfile>alwaysActiveProfile</activeProfile>
  147.     <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  148.   </activeProfiles>
  149.   -->
  150. </settings>
复制代码
maven项目 pom设置

  1. <distributionManagement>
  2.     <repository>
  3.       <id>nexus-releases</id>
  4.       <url>http://nexus地址:端口/repository/maven-releases/</url>
  5.     </repository>
  6.     <snapshotRepository>
  7.       <id>nexus-snapshots</id>
  8.       <url>http://nexus地址:端口/repository/maven-snapshots/</url>
  9.     </snapshotRepository>
  10.   </distributionManagement>
复制代码
测试效果

maven deploy



引用,在项目的pom里添加对应依靠即可
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表