配置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 ...
随机推荐
- windows修改远程桌面端口3389
regedit 按照路径打开,HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-T ...
- mysql配置文件修改
mysql配置文件修改 mkdir –p /data/mysql chown -R mysql.mysql /data/mysql/ vim /etc/my.cnf [mysqld ...
- view之Scroller工具类和GestureDetector的简单用法
转载:http://ipjmc.iteye.com/blog/1615828 Android里Scroller类是为了实现View平滑滚动的一个Helper类.通常在自定义的View时使用,在View ...
- Jmeter(四十二)Jmeter工作原理
“千举万变,其道一也.不离于宗,谓之天人” ----<荀子·儒效>和<庄子·天下> 作为接口测试工具 Jmeter只是作为发起请求的客户端(可以理解为前端),Jmeter是作为 ...
- [UE4]场景截图
要点: 一.鼠标在编辑器关卡中点一下,然后按F9键截图,右下角会出现截图后的文件链接,点击后会自动打开截图文件所在的文件夹.截图的大小正好的关卡视图的大小. 编辑器:F9键截图,只截图关卡视图界面 运 ...
- android adb push 命令
1.获得root权限:adb root 2.设置/system为可读写:adb remount 3.将PC机上文件复制到手机:adb push 文件名 /system/lib
- 在Ubuntu16.04下安装 labelImg
首先按照 http://www.linuxdiyf.com/linux/13934.html 和 http://www.linuxdiyf.com/linux/13934.html 在ubuntu ...
- python re模块和collections
re模块下的常用方法 import re ret = re.findall('a', 'eva egon yuan') # 返回所有满足匹配条件的结果,放在列表里 print(ret) #结果 : [ ...
- scrapy框架之日志等级和请求传参-cookie-代理
一.Scrapy的日志等级 - 在使用scrapy crawl spiderFileName运行程序时,在终端里打印输出的就是scrapy的日志信息. - 日志信息的种类: ERROR : 一般错误 ...
- PHP:引用Phpword导出数据到word文档
下载地址https://www.cnwenhui.cn/html/show-597.html(其中有中文使用手册可以下载看看) 1.首先要下载Phpword类库,放在如下图目录下 2.调用方法 pub ...