配置maven访问nexus,配置项目pom.xml以发布maven项目到nexus中
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中的更多相关文章
- Maven项目pom.xml配置详解
maven项目pom.xml文件配置详解,需要时可以用作参考: <project xmlns="http://maven.apache.org/POM/4.0.0" xmln ...
- 关于导入本地maven项目pom.xml出现missing artifact org....报错处理
一.导入本地maven项目步骤:
- Maven项目pom.xml文件简单解析
Maven项目pom.xml简单解析 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="h ...
- maven项目pom.xml第一行报错
maven项目pom.xml第一行报错 这是第一行:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi= ...
- 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文件中 < ...
- 在idea中打开maven项目pom.xml未识别
在idea中打开maven项目pom.xml没有识别出来,导致idea不能自动下载依赖包, 解决办法是选中pom.xml文件,右键-" add as maven project"
- IDEA Maven项目 pom.xml 找不到 Dependency 依赖
转载: IDEA Maven项目 pom.xml 找不到 Dependency 依赖 如果你的pom.xml中使用了dependencyManagement管理依赖并且添加了你本地仓库中不存在的依赖可 ...
- 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 ...
- Maven简介(五)——pom.xml
6 Maven的pom.xml介绍 6.1 简介 pom.xml文件是Maven进行工作的主要配置文件.在这个文件中我们可以配置Maven项目的groupId.artifactId ...
随机推荐
- 廖雪峰Java1-3流程控制-9break、continue
break跳出循环 int sum=0; for(int i=1; ;i++) { sum =sum + i; if(i == 100) { break; } } System.out.println ...
- Android应用启动会白屏一下的解决办法
设置透明样式,如下:<activity android:name="com.hongfans.cvi.ui.MainActivity" android:configChang ...
- xdcms_3.0.1 | 代码审计
这周的审计任务,这次审计 xdcms . 下面就开始审计之旅. ...
- 做好平衡有多难?谈MMO的职业设计
转自:http://www.gameres.com/804893.html 首先要明确个概念:平衡不是在YY好的职业设计基础上去做调整,而是从游戏设计的开始就要打造一套有标准.可调节的游戏设计框架. ...
- linux的cd、ls、chmod命令
cd ls ls:查看权限 chmod:修改权限
- Select模式和超时
fd_set rset; FD_ZERO(&rset); int nready; int maxfd; int fd_stdin = fileno(stdin); if(fd_stdin &g ...
- system 系统调用、gcc编译过程
system 库函数的功能是执行操作系统的命令或者运行指定的程序 #include <stdio.h> #include <stdlib.h>//引入库 int main() ...
- Elasticsearch简介与安装
搜索 就是在任何场景下,找寻你想要的信息,这个时候,会输入一段你要搜索的关键字,然后就期望找到这个关键字相关的有些信息 垂直搜索 站内搜索 互联网搜索 电商网站,招聘网站,新闻网站,各种app IT系 ...
- Spark2.X环境准备、编译部署及运行
下载地址 :https://www.apache.org/dyn/closer.lua/spark/spark-2.2.0/spark-2.2.0.tgz 我们把spark放在节点2上 解压 下面我们 ...
- FastDFS+Nginx+fastdfs-nginx-module集群搭建
一.实验环境说明 操作系统: Centos 6.6 x64 FastDFS 相关版本: fastdfs-5.05 fastdfs-nginx-module-v1.16 libfastcommon-v1 ...