Archiva与maven配置使用

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

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

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

    
      archiva.internal
      admin
      admin123
    
    
     
      archiva.snapshots
      admin
      admin123
    

1.2 设置存储镜像

    
      archiva.internal
      internal
      internal
      http://118.24.48.158:8088/repository/internal/
    
    
      archiva.snapshots
      snapshots
      snapshots
      http://118.24.48.158:8088/repository/snapshots/
    

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

标签的下增加一个新的


      archiva.internal
      
        true
      
      
        
          internal
          Archiva Managed Internal Repository
          http://118.24.48.158:8088/repository/internal/
          
            true
          
          
            false
          
        
      
      
        
          internal
          Archiva Managed Internal Repository
          http://118.24.48.158:8088/repository/internal/
          
            true
          
          
            false
          
        
      
    
    
      archiva.snapshots
      
        true
      
      
        
          snapshots
          Archiva Managed Snapshot Repository
          http://118.24.48.158:8088/repository/snapshots/
          
            false
          
          
            true
          
        
          
      
        
          snapshots
          Archiva Managed Snapshot Repository
          
          http://118.24.48.158:8088/repository/snapshots/
          
            false
          
          
            true
          
        
      
     

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

  
   
     archiva.internal
     http://192.168.43.45:8080/repository/internal/
   
   
     archiva.snapshots
     http://192.168.43.45:8080/repository/snapshots/
   
 

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

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

mvn clean install deploy

Archiva与maven配置使用_第1张图片

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

Archiva与maven配置使用_第2张图片

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

pom参考如下:

1、internal版本存储:


  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  4.0.0
  com.fjnx.cn
  testJenkins
  war
  1.0.0
  testJenkins Maven Webapp
  http://maven.apache.org
  
    
      junit
      junit
      3.8.1
      test
    
  
  
    testJenkins
  
  
   
     archiva.internal
     http://192.168.43.45:8080/repository/internal/
   
   
     archiva.snapshots
     http://192.168.43.45:8080/repository/snapshots/
   
 

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


  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  4.0.0
  com.fjnx.cn
  testJenkins
  war
  1.0.0-SNAPSHOT
  testJenkins Maven Webapp
  http://maven.apache.org
  
    
      junit
      junit
      3.8.1
      test
    
  
  
    testJenkins
  
  
   
     archiva.internal
     http://192.168.43.45:8080/repository/internal/
   
   
     archiva.snapshots
     http://192.168.43.45:8080/repository/snapshots/
   
 

done!

你可能感兴趣的:(Archiva与maven配置使用)