zoukankan      html  css  js  c++  java
  • 持续集成之路——搭建Maven私服

      在开发过程中,有时候会使用到公司内部的一些开发包,显然把这些包放在外部是不合适的。另外,由于项目一直在开发中,这些内部的依赖可能也在不断的更新。可以通过搭建公司内部的Maven服务器,将第三方和内部的依赖统一管理。

          这里使用Nexus来搭建本地的Maven服务器,过程比较简单。

     

          一、安装服务器

          1、下载

          我们可以在nexus的官网上找到它的相关介绍,下载地址是:http://nexus.sonatype.org/downloads/,在这里可以找到最新的版本,如果需要以前的版本,在官网上应该也可以找到下载地址。我下载的是:nexus-oss-webapp-1.8.0-bundle.tar.gz。关于Nexus的详细使用方法可以参照:Repository Management with Nexus.

          2、安装

          解压下载的文件:

          # tar xzvf nexus-oss-webapp-1.8.0-bundle.tar.gz

          解压后会在同级目录中,出现两个文件夹:nexus-oss-webapp-1.8.0和sonatype-work,前者包含了nexus的运行环境和应用程序,后者包含了你自己的配置和数据。

          3、启动nexus

          在上面的提到,nexus的运行环境在nexus-oss-webapp-1.8.0目录,下面就进入这个目录启动:

          # cd nexus-oss-webapp-1.8.0/bin/jsw/linux-x86-64/

          在这个目录下包含了一个文件夹和三个文件:lib、nexus、platform和wrapper,其中nexus就是启动命令。

          # ./nexus

          执行上面的命令,可以得到nexus命令的用法提示:start 命令启动,stop命令停止。下面启动nexus:

          # ./nexus start

          Starting Nexus OSS...

          Started Nexus OSS

          从控制台输出可以看到Nexus已经启动成功,我们可以通过log文件查看更详细的信息:

          # cd ~/nexus-oss-webapp-1.8.0/log

          # tail -f wrapper.log

          在log中可以看到nexus默认监听的端口是8081。那么我们就可以在浏览器中访问:http://host:8081/nexus,

         

         

           二、配置Nexus

           由于在新搭建的nexus环境中只是一个空的仓库,所以第一步就是要和远程的Maven中心仓库进行同步。

            

          

            

           如果在Reindex之后,并没有同步到远程的仓库,可以检查每个仓库的设置。下面是Maven Central的设置:

     

           

     

           三、在项目中使用私服

          

           在完成了上面的配置后,就可以将项目中默认的Repository切换为本地的私服了,只需要在pom.xml中增加repositories就可以了:

          

    1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    2.   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
    3.   <modelVersion>4.0.0</modelVersion>  
    4.   
    5.   <groupId>org.maven.demo</groupId>  
    6.   <artifactId>MavenDemo</artifactId>  
    7.   <version>0.0.1-SNAPSHOT</version>  
    8.   <packaging>jar</packaging>  
    9.   
    10.   <name>MavenDemo</name>  
    11.   <url>http://maven.apache.org</url>  
    12.   
    13.     <repositories>  
    14.         <repository>  
    15.             <snapshots>  
    16.                 <enabled>true</enabled>  
    17.             </snapshots>  
    18.             <id>public</id>  
    19.             <name>Public Repositories</name>  
    20.             <url>http://172.28.189.138:8081/nexus/content/groups/public/</url>  
    21.         </repository>  
    22.     </repositories>  
    23.     <pluginRepositories>  
    24.         <pluginRepository>  
    25.             <id>public</id>  
    26.             <name>Public Repositories</name>  
    27.             <url>http://172.28.189.138:8081/nexus/content/groups/public/</url>  
    28.         </pluginRepository>  
    29.     </pluginRepositories>  
    30.     <dependencies>  
    31.         <dependency>  
    32.             <groupId>junit</groupId>  
    33.             <artifactId>junit</artifactId>  
    34.             <version>4.8.1</version>  
    35.             <type>jar</type>  
    36.             <scope>compile</scope>  
    37.         </dependency>  
    38.     </dependencies>  
    39.     <properties>  
    40.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
    41.   </properties>  
    42. </project>  

     

           将pom.xml保存后,再回过头来了看去nexus管理界面看,就会发现junit已经被下载到本地的nexus服务器中了。

  • 相关阅读:
    DEDECMS里面DEDE函数解析
    dede数据库类使用方法 $dsql
    DEDE数据库语句 DEDESQL命令批量替换 SQL执行语句
    织梦DedeCms网站更换域名后文章图片路径批量修改
    DSP using MATLAB 示例 Example3.12
    DSP using MATLAB 示例 Example3.11
    DSP using MATLAB 示例 Example3.10
    DSP using MATLAB 示例Example3.9
    DSP using MATLAB 示例Example3.8
    DSP using MATLAB 示例Example3.7
  • 原文地址:https://www.cnblogs.com/chenying99/p/2559660.html
Copyright © 2011-2022 走看看