maven访问nexus有三种配置方法,分别为:

项目pom.xml,优先级最高;

user的settings.xml,优先级中,未在pom.xml中配置repository标签,则使用这个配置;

maven的settings.xml,优先级最低,在项目pom.xml和user的settings.xml都没有配置仓库时,才使用这个配置;

项目pom.xml配置,在pom.xml中添加以下内容:

    <repositories>
<repository>
<id>public</id>
<name>public</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>public</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

以上仓库配置也可以在maven用户的setting.xml文件中(注意localhost应为设计的ip地址或url),如下:

  <profiles>
<profile>
<id>ourRepositoryGroup</id>
<repositories>
<repository>
<id>public</id>
<name>public</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>public</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories> </profile>
</profiles> <activeProfiles>
<activeProfile>ourRepositoryGroup</activeProfile>
</activeProfiles>

关注maven配置文件的优先级,简单的做法是让其保持一致。

以上配置了访问Nexus的Public Repositories仓库组,id和name都无关紧要,要紧的是url必须适配。

发布项目到Nexus,在pom.xml中添加以下内容:

    <!-- 发布项目到Nexus -->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

带源码发布的插件配置,在pom.xml中添加以下内容:

    <build>
<plugins>
<!-- 发布源码,需要这个插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

发布需要nexus登录

在user的settings.xml

        <!--配置nexus仓库认证信息 -->
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

配置maven访问nexus,配置项目pom.xml以发布maven项目到nexus中的更多相关文章

  1. Maven项目pom.xml配置详解

    maven项目pom.xml文件配置详解,需要时可以用作参考: <project xmlns="http://maven.apache.org/POM/4.0.0" xmln ...

  2. 关于导入本地maven项目pom.xml出现missing artifact org....报错处理

    一.导入本地maven项目步骤:

  3. Maven项目pom.xml文件简单解析

    Maven项目pom.xml简单解析 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="h ...

  4. maven项目pom.xml第一行报错

    maven项目pom.xml第一行报错 这是第一行:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi= ...

  5. java maven项目 pom.xml plugin 报错, build path 找不到 jconsole-1.8.0.jar 和 tools-1.8.0.jar 包

    maven项目pom.xml突然报错,在Java Build Path 中并没有引用的jar包出现在了Maven Dependencies的依赖包中. 这个错误直接导致了pom.xml文件中 < ...

  6. 在idea中打开maven项目pom.xml未识别

    在idea中打开maven项目pom.xml没有识别出来,导致idea不能自动下载依赖包, 解决办法是选中pom.xml文件,右键-" add as maven project"

  7. IDEA Maven项目 pom.xml 找不到 Dependency 依赖

    转载: IDEA Maven项目 pom.xml 找不到 Dependency 依赖 如果你的pom.xml中使用了dependencyManagement管理依赖并且添加了你本地仓库中不存在的依赖可 ...

  8. maven项目解决pom.xml头部 http://maven.apache.org/xsd/maven-4.0.0.xsd报错的问题

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/qq_36611526/article/d ...

  9. Maven简介(五)——pom.xml

    6       Maven的pom.xml介绍 6.1     简介 pom.xml文件是Maven进行工作的主要配置文件.在这个文件中我们可以配置Maven项目的groupId.artifactId ...

随机推荐

  1. spring boot (入门简介 demo)

    Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置.通过 ...

  2. 微服务之分布式跟踪系统(springboot+zipkin+mysql)

    通过上一节<微服务之分布式跟踪系统(springboot+zipkin)>我们简单熟悉了zipkin的使用,但是收集的数据都保存在内存中重启后数据丢失,不过zipkin的Storage除了 ...

  3. Java-Runoob-高级教程-实例-方法:13. Java 实例 – for 和 foreach循环使用

    ylbtech-Java-Runoob-高级教程-实例-方法:13. Java 实例 – for 和 foreach循环使用 1.返回顶部 1. Java 实例 - for 和 foreach循环使用 ...

  4. spring 如何决定使用jdk动态代理和cglib(转)

    Spring1.2: 将事务代理工厂[TransactionProxyFactoryBean] 或 自动代理拦截器[BeanNameAutoProxyCreator] 的 proxyTargetCla ...

  5. win server 2008 R2 安装IIS

    IIS是基于windows系统的一个互联网信息服务,可以使用IIS创建网站.FTP站点等服务. 安装IIS 打开服务器管理器,角色,添加角色 下一步 选择"Web服务器(IIS)" ...

  6. python基础介绍

    一. 1.计算机基础 cpu:运算和控制:速度:飞机 内存:临时存储,供给cup数据,断电数据清空.成本高,速度:高铁 硬盘:相当于电脑的数据库,存储大量数据,数据永久保存(除非物理结构被破坏).速度 ...

  7. 事件之onTouch方法的执行过程 及和 onClick执行发生冲突的解决办法

    转载:http://blog.csdn.net/jiangwei0910410003/article/details/17504315#quote 博主推荐: 风萧兮兮易水寒,“天真”一去兮不复还.如 ...

  8. int, bool, string的操作

    基本数据类型 1.int型 可以求整数的二进制长度.输入一个数字a,"a.bit_length()"语法求a的二进制长度. a = 3 #二进制为11 print(a.bit_le ...

  9. 【 MAKEFILE 编程基础之三】详解 MAKEFILE 变量的定义规则使用!

    本站文章均为 李华明Himi 原创,转载务必在明显处注明: 转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/gcc-makefile/770.html   ...

  10. video兼容--可用

    兼容ie6,7,8,但是播放器会卡顿黑屏<!DOCTYPE html> <html lang="en"> <head> <meta cha ...