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. Java-Runoob-高级教程-实例-数组:16. Java 实例 - 数组并集

    ylbtech-Java-Runoob-高级教程-实例-数组:16. Java 实例 - 数组并集 1.返回顶部 1. Java 实例 - 数组并集  Java 实例 以下实例演示了如何使用 unio ...

  2. [转][EasyUI]扩展 DateBox

    /** * 给时间框控件扩展一个清除的按钮 */ $.fn.datebox.defaults.cleanText = '清空'; (function ($) { var buttons = $.ext ...

  3. bundle adjustment 玩具程序

    结合 bundle adjustment原理(1) 和 Levenberg-Marquardt 的 MATLAB 代码 两篇博客的成果,调用MATLAB R2016a中 bundleAdjustmen ...

  4. Jmeter(五)录制功能

    难得休息时间,和开发对完需求便理着Jmeter的知识的相关体系,趁闲暇功夫就记一点,希望这么坚持下去,能有很多关于Jmeter的知识点被总结,被挖掘出来,从而形成自己的一套知识体系..... 嗯,那本 ...

  5. Scala 入门详解

    Scala 入门详解 基本语法 Scala 与 Java 的最大区别是:Scala 语句末尾的分号 ; 是可选的 Scala 程序是对象的集合,通过调用彼此的方法来实现消息传递.类,对象,方法,实例变 ...

  6. Elasticsearch分布式机制探究

    Elasticsearch是一套分布式的系统,分布式是为了应对大数据量隐藏了复杂的分布式机制 分片机制 shard = hash(routing) % number_of_primary_shards ...

  7. 使用Solrj 获取语句分词结果的代码

    import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.log4 ...

  8. 删除n天前的所有目录和文件

    删除目录 find /your_dir/ -maxdepth -type d -mtime + -exec rm -rf {} \; 删除文件 find /目录/ -mtime + -name &qu ...

  9. pytho 单例模式

    单例模式存在的目的是保证当前内存中仅存在单个实例,避免内存浪费!!! (程序如果并发量大的话,内存里就会存在非常多功能上一模一样的对象.存在这些对象肯定会消耗内存,对于这些功能相同的对象可以在内存中仅 ...

  10. python-异常

    实例:https://www.cnblogs.com/tangpg/p/7992979.html 在系统内部,解释器使用一种被称为 ‘块栈’的结构处理异常逻辑.它和执行栈一起被栈帧管理.块栈在运行期间 ...