Java第四十五天,Maven高级篇(三),私服

一、安装私服

1.下载 Nexus

方法一:到Nexus 官网下载Nexus

https://www.sonatype.com/

方法二:我的分享

https://download.csdn.net/download/ITlanyue/12736638

2.解压到指定目录(无中文、特殊字符)

3.安装

(1)以管理员身份运行 cmd ,进入 nexus 软件的 bin 目录

(2)运行以下命令

nexus.bat install

(3)检查服务是否自动

4.启动与关闭

  • nexus.bat start ===> 启动服务
  • nexus.bat stop ===> 关闭服务

5.卸载

nexus.bat uninstall

6.修改 nexus 服务端口号

通过修改软件 /conf/nexus.properties 配置文件的 application-port 键值修改

7.浏览器访问 nexus UI 界面

浏览器通过以下路径访问(端口默认为 8081 )

http://127.0.0.1:8081/nexus/#welcome

用户名和密码默认如下

  • 用户名:admin
  • 密码:admin123

8.nexus 仓库种类

二、本地仓库与私服的上传下载

1.利用 Maven 项目登录私服

在 maven 软件的 settings.xml 配置文件中的 <servers/> 标签内部配置如下标签

1<servers> 2 ...... 3 <server> 4 <id>releases</id> 5 <username>admin</username> 6 <password>admin123</password> 7 </server> 8 <server> 9 <id>snapshots</id> 10 <username>admin</username> 11 <password>admin123</password> 12 </server> 13</servers>

2.上传本地项目或模块到私服

(1)在需要上传的子模块的 pom.xml 配置文件中添加如下标签

1<distributionManagement> 2 <repository> 3 <!--id 和 url 需要核对准确--> 4 <id>releases</id> 5 <url>http://localhost:8081/nexus/content/repositories/releases/</url> 6 </repository> 7 <snapshotRepository> 8 <!--id 和 url 需要核对准确--> 9 <id>snapshots</id> 10 <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> 11 </snapshotRepository> 12</distributionManagement>

(2)在需要上传的子模块中运行生命周期中的 deploy 生命周期命令

3.从私服下载本地所需的工程或模块

在 maven 的 settings.xml 配置文件中的 <profiles> 标签中添加如下标签

1<!-- 下载jar包配置 --> 2<profile> 3 <!--profile的id --> 4 <id>dev</id> 5 <repositories> 6 <repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 --> 7 <id>nexus</id> <!--仓库地址,即nexus仓库组的地址 --> 8 <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 --> 9 <releases> 10 <enabled>true</enabled> 11 </releases> <!--是否下载snapshots构件 --> 12 <snapshots> 13 <enabled>true</enabled> 14 </snapshots> 15 </repository> 16 </repositories> 17 <pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 --> 18 <pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 --> 19 <id>public</id> 20 <name>Public Repositories</name> 21 <url>http://localhost:8081/nexus/content/groups/public/</url> 22 </pluginRepository> 23 </pluginRepositories> 24</profile> 25 26 27<!--激活下载--> 28<activeProfiles> 29 <!--id 需要与上面的 id 对应--> 30 <activeProfile>dev</activeProfile> 31</activeProfiles>

三、上传第三方 jar 包到私服

1.安装第三方 jar 包到本地仓库

需要提前知道 第三方 jar包 的坐标

1// 安装第三方jar包到本地仓库 2 3// 方法一:进入jar包所在目录运行 4mvn install:install-file -DgroupId=项目组织名 -DartifactId=项目名 -Dversion=版本号 -Dfile=第三方jar包文件名.jar -Dpackaging=jar 5 6// 方法二:打开cmd直接运行 7mvn install:install-file -DgroupId=项目组织名 -DartifactId=项目名 -Dversion=版本号 -Dpackaging=jar -Dfile=第三方jar包路径+文件名.jar

2.安装第三方 jar 包到私服

在 Maven 软件的 settings.xml 配置文件中的 <servers/> 标签中添加如下代码

1<server> 2 <!--自己私服的第三方包id--> 3 <id>thirdparty</id> 4 <!--用户名;默认为 admin--> 5 <username>admin</username> 6 <!--密码;默认为 admin123--> 7 <password>admin123</password> 8</server>

使用如下命令上传第三方 jar包 到私服

1// 进入jar包所在目录运行 2mvn deploy:deploy-file -DgroupId=第三方jar包项目组织名 -DartifactId=第三方jar包项目名 -Dversion=第三方jar包项目版本号 -Dpackaging=jar -Dfile=第三方jar包文件名.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty 3 4// 打开cmd直接运行 5mvn deploy:deploy-file -DgroupId=第三方jar包项目组织名 -DartifactId=第三方jar包项目名 -Dversion=第三方jar包项目版本号 -Dpackaging=jar -Dfile=第三方jar包路径+文件名.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

Java日期时间API系列31

  时间戳是指格林威治时间1970年01月01日00时00分00秒起至现在的总毫秒数,是所有时间的基础,其他时间可以通过时间戳转换得到。Java中本来已经有相关获取时间戳的方法,Java8后增加新的类Instant等专用于处理时间戳问题。 1获取时间戳的方法和性能对比1.1获取时间戳方法Java8以前

Android So动态加载 优雅实现与原理分析

背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我

mysql设置时区

mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0