欢迎光临
我们一直在努力

精简nexus私服搭建

maven对项目源码和依赖管理的好处不言而喻,不过所依赖仓库都是外网那些常用提供的仓库地址,基于安全,当外网环境有限制,或私有共通jar需共享时,则会需要搭建内部私服,以下说明基于Linux环境。

1. maven 安装   安装很简单,主要就几个步骤和设置。

a.  wget 安装包下载地址;   b.  tar zxvf 压缩的安装包 (如果需要安装到指定位置将包移动 : mv  源路径  目的地址; );  

c. 配置环境变量   编辑 vi /etc/profile  且增加  export MAVEN_HOME=解压路径 与 export PATH=$PATH:$MAVEN_HOME/bin  d. 配置生效  source /etc/profile   e.验证 mvn -v。

2. 安装nexus  (据说不提倡用 nexus3.x 以上版本,用nexus2.x版本 , JDK版本1.7以上)

a. 下载nexus2.x 安装包 b. 解压  tar  zxvf   安装包;   c.  如改端口在  /conf/nexus.properties  d.  启动运行 切到  cd nexus-2.x/bin  再执行  ./nexus  start

              精简nexus私服搭建

注意:可能会报错,报上面错误时:需要修改运行的用户,修改运行文件 nexus,命令:vim nexus,将RUN_AS_USER修改为root;

 

e. 访问  http://xxx.xxx.xxx.xx:8081/nexus/   默认 admin/admin123  (如果启动要root权限 用 sudo sh nexus  start启动 )

3. 私服仓库使用及管理 

a. 登录进去,nexus默认会有已创建的常用仓库分类,含 snapshots:开发过程中的版本仓库  release:正式发布的版本仓库  public:maven主库  3rd party,存第三方的jar

b. maven setting.xml设置  (注意 两个xml  对应 id保持一致 )

<servers>

<server>
    <id>releases</id>
        <username>admin</username>
    <password>admin123</password>
</server>
<server>
     <id>snapshots</id>
        <username>admin</username>
     <password>admin123</password>    
</server>       
                       
<server>
        <id>public</id>
        <username>admin</username>
        <password>admin123</password>
</server>
</servers>

c. maven pom.xml设置 

   <groupId> News_Recommend</groupId>
   <artifactId> News_Recommend</artifactId>
   <version> 0.0.1-SNAPSHOT</version>
   <packaging> jar</packaging>

<!-- 设定主仓库 -->
<repositories>
<!-- nexus私服 -->
<repository>
<id> public</id>
<url> http://xxxx:8081/nexus/content/groups/public/ </url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
 
<!-- 自动打包 -->
    <distributionManagement>
        <repository>
            <id>releases</id>
            < url> http://xxxx:8081/nexus/content/repositories/releases </url >
        </repository>
        <snapshotRepository>
            <id>snapshots </id>
            <url> http://xxxx:8081/nexus/content/repositories/snapshots </url >
        </snapshotRepository >
    </distributionManagement >

d. 打成jar上传私服  工程右键-->run as-->run configuration   进入 nexus后台可看到上传的jar , 如要release版本  <version> 0.0.1-SNAPSHOT</version> 改   <version> 0.0.1</version>

参考 http://www.cnblogs.com/zhongshengzhen/p/nexus_maven.html

 

 

 

  • 海报
海报图正在生成中...
赞(0) 打赏
声明:
1、本博客不从事任何主机及服务器租赁业务,不参与任何交易,也绝非中介。博客内容仅记录博主个人感兴趣的服务器测评结果及一些服务器相关的优惠活动,信息均摘自网络或来自服务商主动提供;所以对本博客提及的内容不作直接、间接、法定、约定的保证,博客内容也不具备任何参考价值及引导作用,访问者需自行甄别。
2、访问本博客请务必遵守有关互联网的相关法律、规定与规则;不能利用本博客所提及的内容从事任何违法、违规操作;否则造成的一切后果由访问者自行承担。
3、未成年人及不能独立承担法律责任的个人及群体请勿访问本博客。
4、一旦您访问本博客,即表示您已经知晓并接受了以上声明通告。
文章名称:《精简nexus私服搭建》
文章链接:https://www.456zj.com/38123.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址