zoukankan      html  css  js  c++  java
  • Archiva与maven配置使用

    在之前的博文里头已经介绍了Archiva私服的使用,本文主要介绍,如何与maven进行配置,在进行maven使用的时候可以自动上传至Archiva上

    1、设置maven的用户配置,到maven的安装目录下/conf/setting.xml,参考以下配置修改:

    1.1 认证信息就是你在仓库管理中设置的user,而在本地,需要在<servers>标签下新增<server>:

        <server>
          <id>archiva.internal</id>
          <username>admin</username>
          <password>admin123</password>
        </server>
        
         <server>
          <id>archiva.snapshots</id>
          <username>admin</username>
          <password>admin123</password>
        </server>

    1.2 设置存储镜像

        <mirror>
          <id>archiva.internal</id>
          <mirrorOf>internal</mirrorOf>
          <name>internal</name>
          <url>http://118.24.48.158:8088/repository/internal/</url>
        </mirror>
        <mirror>
          <id>archiva.snapshots</id>
          <mirrorOf>snapshots</mirrorOf>
          <name>snapshots</name>
          <url>http://118.24.48.158:8088/repository/snapshots/</url>
        </mirror>

    1.3 这里有两种方式,第一种是将私有仓库作为唯一的仓库使用(私有仓库作为远程仓库的代理使用);第二种是将私有仓库作为仓库列表中的一个使用。考虑到笔者所处的网络环境,所以选择了第二种方式 。 

    在<settings>标签的<profiles>下增加一个新的<profile>:

    <profile>
          <id>archiva.internal</id>
          <activation>
            <activeByDefault>true</activeByDefault>
          </activation>
          <repositories>
            <repository>
              <id>internal</id>
              <name>Archiva Managed Internal Repository</name>
              <url>http://118.24.48.158:8088/repository/internal/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>internal</id>
              <name>Archiva Managed Internal Repository</name>
              <url>http://118.24.48.158:8088/repository/internal/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>
        <profile>
          <id>archiva.snapshots</id>
          <activation>
            <activeByDefault>true</activeByDefault>
          </activation>
          <repositories>
            <repository>
              <id>snapshots</id>
              <name>Archiva Managed Snapshot Repository</name>
              <url>http://118.24.48.158:8088/repository/snapshots/</url>
              <releases>
                <enabled>false</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
          </repositories>    
          <pluginRepositories>
            <pluginRepository>
              <id>snapshots</id>
              <name>Archiva Managed Snapshot Repository</name>
              <!--远程服务器IP-->
              <url>http://118.24.48.158:8088/repository/snapshots/</url>
              <releases>
                <enabled>false</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </pluginRepository>
          </pluginRepositories>
         </profile>

    1.4 在项目的pom.xml文件里头新增仓库

      <distributionManagement>
       <repository>
         <id>archiva.internal</id>
         <url>http://192.168.43.45:8080/repository/internal/</url>
       </repository>
       <snapshotRepository>
         <id>archiva.snapshots</id>
         <url>http://192.168.43.45:8080/repository/snapshots/</url>
       </snapshotRepository>
     </distributionManagement>

    注意:这里的id要和<server>中配置的id一致。

    2、新建一个maven项目,参考步骤1配置相关属性,然后在控制台输入命令:

    mvn clean install deploy

    相关的war已经上传Archiva私服上,我们到私服看下:

    附件:maven工程可以参考git:https://github.com/shawwey/testJenkins

    pom参考如下:

    1、internal版本存储:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.fjnx.cn</groupId>
      <artifactId>testJenkins</artifactId>
      <packaging>war</packaging>
      <version>1.0.0</version>
      <name>testJenkins Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <finalName>testJenkins</finalName>
      </build>
      <distributionManagement>
       <repository>
         <id>archiva.internal</id>
         <url>http://192.168.43.45:8080/repository/internal/</url>
       </repository>
       <snapshotRepository>
         <id>archiva.snapshots</id>
         <url>http://192.168.43.45:8080/repository/snapshots/</url>
       </snapshotRepository>
     </distributionManagement>
    </project>

    2、snapshots快照版本,区别所在只是版本后面加个"-SANPSHOT"

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.fjnx.cn</groupId>
      <artifactId>testJenkins</artifactId>
      <packaging>war</packaging>
      <version>1.0.0-SNAPSHOT</version>
      <name>testJenkins Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <finalName>testJenkins</finalName>
      </build>
      <distributionManagement>
       <repository>
         <id>archiva.internal</id>
         <url>http://192.168.43.45:8080/repository/internal/</url>
       </repository>
       <snapshotRepository>
         <id>archiva.snapshots</id>
         <url>http://192.168.43.45:8080/repository/snapshots/</url>
       </snapshotRepository>
     </distributionManagement>
    </project>

    done!

  • 相关阅读:
    MySQL事务知识要点(一)
    MySQL 安全体系知识要点
    MySQL 安全性知识要点
    #翻译#通往SQL Server安全级别2的阶梯:身份验证; 唐•吉利; 原文链接:Stairway to SQL Server Security Level 2: Authentication http://www.sqlservercentral.com/articles/Stairway+Series/109975/
    SQL子查询&视图&更新&删除思维导图-误点难点(附示例代码)
    #翻译#通往t
    香港中文大学-人脸识别进展-2014-06
    NotesMITLinearAlgebra
    Notes Berkerly Statistics 2.1X Week4
    Notes on Brain Study
  • 原文地址:https://www.cnblogs.com/shawWey/p/10483782.html
Copyright © 2011-2022 走看看