使用私有的nexus仓库进行maven构建

出现了一个特殊的需求,有一个项目需要用它自己的nexus仓库进行maven构建,又不想另搞一套maven,所以构建的时候要指定配置文件,比如日常mvn操作是这样的

mvn clean install -DskipTests -e

为了指定配置文件,就需要改成这样的

mvn clean install -s /app/apache-maven-3.5.4/conf/new-settings.xml -DskipTests -e

所以关键就是new-settings.xml该怎么写,这也是最大的坑,这么写。主要是注意写mirrors这一块,否则mvn不认你的新仓库

<?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">
  <localRepository>/app/apache-maven-3.5.4/repository_gateway</localRepository>
  <pluginGroups></pluginGroups>
  <proxies></proxies>
  <mirrors>
    <mirror>
      <id>new-repo</id>
      <mirrorOf>new-repo</mirrorOf>
      <name>new-repo</name>
      <url>http://new-nexus-url/new-repo</url>
    </mirror>
  </mirrors>
  <servers>
    <server>
      <id>new-repo</id>
      <username>xxxxx</username>
      <password>xxxxxx</password>
    </server>
  </servers>
  <profiles>
    <profile>
      <id>msmart</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
      <repositories>
        <repository>
          <id>snapshots-repo</id>
          <name>snapshots-repo</name>
          <url>http://new-nexus-url/new-repo</url>
          <releases>
            <enabled>false</enabled>
			      <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
			<updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>your-own</activeProfile>
  </activeProfiles>
</settings>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值