maven私服

1.上傳jar包到私服

  首先私服認證:json

<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>maven

pom.xml指定url

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

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

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

 

3.部署blog

  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>get

          <!--老是從私服更新最新的構件 版本-->it

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

相關文章
相關標籤/搜索