如何配置并使用maven私服?

2026-05-21 11:173阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计729个文字,预计阅读时间需要3分钟。

如何配置并使用maven私服?

Maven仓库分为本地仓库、远程仓库和私有仓库。私有仓库通常是公司内部使用的,用于存放私有依赖。员工连接私有仓库,可下载jar包,或将自身jar上传至私有仓库。私有仓库还可以从‘获取资源。

maven的仓库分为本地仓库,远程仓库和私服仓库。

私服仓库一般是公司内部私有的,内部进行维护的。公司员工连接私服,从私服中下载jar,或者将自身的jar传到私服上。私服还可以从中央仓库下载jar,当私服中没用jar的时候,就会从中央仓库下载。

搭建私服下载

下载 Nexus,下载地址:www.sonatype.org/nexus/archived/ 。

可以选择zip和tar,分别对应windows和linux。

安装

将下载的zip解压,使用cmd进入bin目录,执行命令:

nexus.bat install

卸载

执行命令:

nexus.bat uninstall

启动

1、cmd进入目录,执行命令

nexus.bat start

2、在服务中找到nexus,右键启动

nexus配置文件详细

查看 nexus 的配置文件conf/nexus.properties
application-port=8081 # nexus 的访问端口配置
application-host=0.0.0.0 # nexus 主机监听配置(不用修改)
nexus-webapp=${bundleBasedir}/nexus # nexus 工程目录
nexus-webapp-context-path=/nexus # nexus 的 web 访问路径
nexus-work=${bundleBasedir}/../sonatype-work/nexus # nexus 仓库目录
runtime=${bundleBasedir}/nexus/WEB-INF # nexus 运行程序目录

访问私服

localhost:8081/nexus/


点击右上角log in,输入用户名和密码


默认是admin/admin123

登录完毕

上传jar包到私服

在maven的setting.xml中配置

<server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server>

配置项目的pom文件

如何配置并使用maven私服?

<distributionManagement> <repository> <id>releases</id> <url>localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>

使用deploy命令即可将jar发布到私服,发布工程中的version,如果以snapshot结尾,则可以发布到快照仓库,如果以release结尾,则可以发布到releases版本。

从私服下载jar包

在setting中配置私服仓库

<distributionManagement> <repository> <id>releases</id> <url>localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>

激活

<activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>

到此这篇关于maven私服的配置使用方法的文章就介绍到这了,更多相关maven私服配置使用内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

标签:仓库

本文共计729个文字,预计阅读时间需要3分钟。

如何配置并使用maven私服?

Maven仓库分为本地仓库、远程仓库和私有仓库。私有仓库通常是公司内部使用的,用于存放私有依赖。员工连接私有仓库,可下载jar包,或将自身jar上传至私有仓库。私有仓库还可以从‘获取资源。

maven的仓库分为本地仓库,远程仓库和私服仓库。

私服仓库一般是公司内部私有的,内部进行维护的。公司员工连接私服,从私服中下载jar,或者将自身的jar传到私服上。私服还可以从中央仓库下载jar,当私服中没用jar的时候,就会从中央仓库下载。

搭建私服下载

下载 Nexus,下载地址:www.sonatype.org/nexus/archived/ 。

可以选择zip和tar,分别对应windows和linux。

安装

将下载的zip解压,使用cmd进入bin目录,执行命令:

nexus.bat install

卸载

执行命令:

nexus.bat uninstall

启动

1、cmd进入目录,执行命令

nexus.bat start

2、在服务中找到nexus,右键启动

nexus配置文件详细

查看 nexus 的配置文件conf/nexus.properties
application-port=8081 # nexus 的访问端口配置
application-host=0.0.0.0 # nexus 主机监听配置(不用修改)
nexus-webapp=${bundleBasedir}/nexus # nexus 工程目录
nexus-webapp-context-path=/nexus # nexus 的 web 访问路径
nexus-work=${bundleBasedir}/../sonatype-work/nexus # nexus 仓库目录
runtime=${bundleBasedir}/nexus/WEB-INF # nexus 运行程序目录

访问私服

localhost:8081/nexus/


点击右上角log in,输入用户名和密码


默认是admin/admin123

登录完毕

上传jar包到私服

在maven的setting.xml中配置

<server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server>

配置项目的pom文件

如何配置并使用maven私服?

<distributionManagement> <repository> <id>releases</id> <url>localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>

使用deploy命令即可将jar发布到私服,发布工程中的version,如果以snapshot结尾,则可以发布到快照仓库,如果以release结尾,则可以发布到releases版本。

从私服下载jar包

在setting中配置私服仓库

<distributionManagement> <repository> <id>releases</id> <url>localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>

激活

<activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>

到此这篇关于maven私服的配置使用方法的文章就介绍到这了,更多相关maven私服配置使用内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

标签:仓库