maven私服

1.上传jar包到私服

  首先私服认证:

<servers>
  <server>
    <id>nexus-releases</id>
    <username>admin</username>
    <password>admin321</password>
  </server>
  <server>
    <id>nexus-snapshots</id>
    <username>admin</username>
    <password>admin321</password>
  </server>
  <server>
    <id>3rdParty</id>
    <username>admin</username>
    <password>admin321</password>
  </server>
</servers>

pom.xml指定

<distributionManagement>
  <repository>
    <id>nexus-releases</id>
    <name>releases Repository</name>
    <url>http://127.0.0.1:8081/repository/maven-releases/</url>
  </repository>

  <repository>
    <id>nexus-snapshots</id>
    <name>snapshots Repository</name>
    <url>http://127.0.0.1:8081/repository/maven-snapshots/</url>
  </repository>

  <repository>
    <id>3rdParty</id>
    <name>3rdParty Repository</name>
    <url>http://127.0.0.1:8081/repository/3rdParty/</url>
  </repository>
</distributionManagement>

 

3.部署

  mvn deploy:deploy-file -DgroupId=net.sf -DartifactId=json-lib -Dversion=2.4 -Dpackaging=jar -Dfile=E:/json-lib-2.4.jar -Durl=http://192.168.1.222/nexus/repository/releases/ -DrepositoryId=nexus-releases
2.从私服上下载jar

<profiles>
  <profile>
    <id>jdk1.8</id>
    <!--表示当没有指定其他profile为激活状态时,该profile就默认会被激活   mvn package –P profileTest2(id)的时候将激活profileTest2 <jdk>1.5</jdk>   jdk1.5激活-->
    <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>maven-public</id>
        <url>http://192.168.124.13:8081/repository/maven-public/</url>

        <!--告诉Maven可以从这个仓库下载releases版本的构件, 为false表示仓库发行jar不可下载(版本不稳定使用)-->
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
          <updatePolicy>always</updatePolicy>
        </snapshots>
      </repository>
      <repository>
        <id>3rdParty</id>
        <url>http://192.168.124.13:8081/repository/3rdParty/</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>

          <!--总是从私服更新最新的构件 版本-->

          <updatePolicy>always</updatePolicy>
        </snapshots>
      </repository>
   </repositories>
  </profile>
</profiles>

 

posted @ 2019-09-29 15:13  絵飛ヾ的魚  阅读(186)  评论(0编辑  收藏  举报