MAVEN大白话笔记(三):maven在nexus私服上进行发布和下载

4 篇文章 1 订阅
2 篇文章 0 订阅

MAVEN大白话笔记(三):maven在nexus私服上进行发布和下载

(一)setting.xml文件配置

配置servers:

<servers>
    <server>
      <id>releases</id>    <!-- nexus私服配置的仓库id,releases通常是值正式版本库 -->
      <username>developer</username>    <!-- nexus私服里面配置的用户账号 -->
      <password>123456</password>    <!-- nexus私服里面配置的用户密码 -->
    </server>

    <server>
      <id>snapshots</id>    <!-- nexus私服配置的仓库id,snapshots通常是值开发版本库 -->
      <username>developer</username>
      <password>123456</password>
    </server>
<servers>

这里的releases和snapshots是指nexus仓库的id,而username和password则是nexus仓库配置的用户id和密码。
这里就不叙述nexus的配置和使用了,想要了解的朋友可以看我写的一篇有关nexus简易使用的文章:https://blog.csdn.net/codeljy/article/details/81298866

配置profiles:

<profiles>
    <profile>
      <id>nexusProfile</id>    <!-- profile的id,不能重复 -->
      <repositories>    <!-- 仓库组 -->
        <repository>    <!-- 一个仓库 -->
            <id>public</id>    <!-- 仓库的id -->
            <url>http://localhost:8081/nexus/content/groups/public/</url>    <!-- 仓库url -->
            <snapshots>
                <enabled>true</enabled>    <!-- 能否使用开发版本库 -->
            </snapshots>
            <releases>
                <enabled>true</enabled>    <!-- 能否使用正式版本库 -->
            </releases>
            <layout>default</layout>    <!-- 设置为default即可,具体有什么用,没研究过,知道得朋友欢迎在评论里面留言 -->
        </repository>
      </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>nexusProfile</activeProfile>    <!-- 设置生效的profile -->
</activeProfiles>

(二)配置pom文件

配置distributionManagement:

<!-- 打包到私服的配置 -->
  <distributionManagement>
    <repository>    <!-- 正式版本库 -->
      <id>releases</id>    <!-- 这里的id必须和你在setting.xml中配置的server的id保持一致 -->
      <name>releases</name>    <!-- 名称随意 -->
      <url>http://localhost:8081/nexus/content/repositories/releases</url>    <!-- 这是nexus私服对应的仓库地址url -->
    </repository>
    <snapshotRepository>    <!-- 开发版本库 -->
      <id>snapshots</id>
      <name>snapshots</name>
      <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

配置源码打包插件:
是否要打包源码,根据公司需要来决定。

<!-- 打包提交到私服时,把源码打上 -->
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>verify</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

(三)执行打包部署命令

mvn clean deploy
这里写图片描述
这里写图片描述
这里写图片描述
有了

(四)从nexus私服下载

加入依赖,然后Reimport一下maven就好了,前提是配置好setting.xml和pom文件。
若是eclipse则update一下maven即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值