为maven搭建私服

为maven搭建私服 
1、搭建maven私服对象有很多,如artifactory、Nexus等,我们以nexus为例,介绍maven私服搭建 
2、下载nexus,http://nexus.sonatype.org/download-nexus.html,有war和zip两个可供选择, 
war下载后须要安排到一个application server中,zip包自带jetty办事器,解压后自行启动 
3、tar -zvxf nexus-oss-webapp-1.9.2.2-bundle.tar.gz, 
cd nexus-oss-webapp-1.9.2.2 
mv nexus-oss-webapp-1.9.2.2 nexus 
cd /usr/local/nexus/bin/jsw/linux-x86-64 
履行./nexus start,即可启动nexus 
4、浏览器接见http://localhost:8081/nexus/index.html,正常打开ok,未登录时,只能显示Repositories一个菜单,用默认的admin/admin123登录,左侧显示所有菜单。默认景象下私服中已经后很多jar,我们可以手工添加一些jar. 
5、选择Repositories-》3rdparty-》artifactsupload,该tab页下可以把我们本地的jar上传到私服仓库中,GAV Definition选择GAV Parameters,然后点击Select Artifact(s) to Upload..选择要上传的jar文件即可 

以上过程就是全部私服搭建的过程,剩下就是我们怎么在maven中从本身搭建的私服中下载指定的jar包,以下省略maven本地的安装过程。 
1、maven设备好后,凡是会在C:Documents and Settings当前用户名.m2目次下有个setting.xml文件,若是没有,可以从maven安装路径下的conf目次拷贝, 
2、在setting.xml文件的<profiles>标签中新加以下内容 
<profile> 
      <id>nexus</id> 
      <repositories> 
        <repository> 
        <id>nexus</id> 
            <name>215 private nexus</name> 
            <url>http://私服地址:8081/nexus/content/groups/public</url> 
            <releases><enabled>true</enabled></releases> 
            <snapshots><enabled>true</enabled></snapshots> 
        </repository> 
       
      </repositories> 
      <pluginRepositories> 
        <pluginRepository> 
            <id>nexus</id> 
            <name>local private nexus</name> 
            <url>http://10.10.1.215:8081/nexus/content/groups/public</url> 
            <releases><enabled>true</enabled></releases> 
            <snapshots><enabled>true</enabled></snapshots> 
        </pluginRepository>       
       </pluginRepositories> 
    </profile>  
  
    <activeProfiles> 
        <activeProfile>nexus</activeProfile> 
  </activeProfiles>   

3、在我们项目中的pom.xml文件中添加依附的jar 
   <dependency> 
      <groupId>test_jar</groupId> 
      <artifactId>test</artifactId> 
      <version>1.3</version> 
    </dependency> 
完成以上步调就大功成功啦! 

原文地址:https://www.cnblogs.com/xuzhenmin/p/3171019.html