nexus搭建与maven指定

    由于晚上使用maven中央库资源构建项目时,可能会遇到maven中央库繁忙一直处于等待,以此为契,搭建私有库。

 

    先给个nexus的下载地址http://www.sonatype.org/nexus/archived/

 

    nexus-2.11.1-01-bundle.zip 本人使用版本

 

 第一步,解压到你想要的目录

 

第二步 安装nexus服务 并打开

 

jsw目录下有各种操作系统的服务版本

 

 

其中install-nexus.bat是用来在操作系统下安装该服务使用的,注意要用管理员身份运行

start-nexus.bat 打开服务

stop-nexus.bat 关闭服务

uninstall-nexus.bat 卸载该服务

我们只需要 执行install-nexus.bat  start-nexus.bat 即可 打开服务管理器查看该服务状态

 

 

第三步 

 

  打开浏览器查看

 

右上角有个login 账号密码  默认 admin  admin123

登录,单击左侧图中选项,列出默认资源库

第四步

添加一个代理库,一般中央库使用 http://repo1.maven.org/maven2/ 即可

 

 

 

 

第五步 索引下载完成后则可以指定maven项目使用该私服了

 

 

settings.xml 内容

  <mirror>
            <id>wings</id>  //库id
            <mirrorOf>*</mirrorOf>
            <url>http://localhost:8081/nexus/content/repositories/wings</url> //地址
        </mirror>
<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <mirrors>
        <mirror>
            <id>wings</id>
            <mirrorOf>*</mirrorOf>
            <url>http://localhost:8081/nexus/content/repositories/wings</url>
        </mirror>
    </mirrors>
    <servers>
        <server>
            <id>nexus-releases</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <server>
            <id>nexus-snapshots</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>central/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

 

这样就完成了。如果发现有自己的私服有该jar包就使用自己的,如果没有就使用中央库的。

 

转载于:https://www.cnblogs.com/zipengwings/p/4849490.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
搭建Maven私服可以使用Sonatype Nexus,它是一个功能强大的仓库管理器,可以帮助我们创建和管理Maven私服。下面是基于Nexus搭建Maven私服的详细步骤: 1. 准备环境:首先,确保你已经安装了Java环境,并且可以正常运行MavenNexus软件。 2. 下载和解压缩Nexus软件:从Sonatype官方网站下载最新版本的Nexus软件,并解压缩到合适的目录中。 3. 启动Nexus:使用命令行窗口进入Nexus软件的目录,然后执行 `./bin/nexus start` 命令来启动Nexus服务器。 4. 访问Nexus控制台:在浏览器中输入 `http://localhost:8081` 访问Nexus控制台,默认用户名和密码都是 `admin`,登录成功后,可以看到Nexus的管理界面。 5. 创建Maven仓库:在Nexus控制台中,点击左侧菜单的 `Repositories`,然后点击 `Create repository` 来创建新的Maven仓库。根据需要选择 `Hosted repository` 或者 `Proxy repository`,然后填写相应的配置信息,如仓库名称、URL、布局等。 6. 配置Maven项目:在你的Maven项目的pom.xml文件中添加Nexus私服的配置信息,包括ID、URL等,用来指定Maven构建输出部署到Nexus仓库中。 7. 部署和使用:使用 `mvn deploy` 命令将项目打包并部署到Nexus私服中,当其他开发人员或者CI/CD服务器需要下载依赖时,只需要修改项目的settings.xml文件,指定Nexus私服的URL和凭据即可。 8. 其他设置:你还可以在Nexus控制台里进行其他设置,比如用户管理、访问控制、仓库代理等。 总结一下,使用Nexus搭建Maven私服非常简单,只需要几个基本的步骤即可完成。通过搭建Maven私服,我们可以有效地管理和共享项目的依赖包,提升团队的开发效率和项目的可维护性。这对于生产环境中的项目非常重要。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值