Java maven三种仓库,本地仓库, * ,中央仓库的配置
作者:NY_Laity 时间:2023-04-13 12:05:17
目录
* 仓库的配置
1、 下载sonatype Nexus来搭建 *
2 安装nexus服务
3、创建 * 仓库
4、配置 * 信息
中央仓库的配置
三个仓库之间的关系
总结
* 仓库的配置
* 仓库的配置比较复杂。
1、 下载sonatype Nexus来搭建 *
我们可以自己去下载https://www.sonatype.com/download-oss-sonatype。下载如下文件。下载速度比较慢,这里提供一个自己的百度云盘下载链接,大家可以去网盘下载:https://pan.baidu.com/s/1RKI7ZytnH89qpPcr3KuuEg。提取码:e61q
下载该文件后对该文件进行解压缩,进入D:\nexus-2.14.4-03-bundle\nexus-2.14.4-03\bin\jsw目录下可以看到很多文件夹,然后根据自己机器的操作系统选择相应的目录,本文以64位Windows操作系统为例。
2 安装nexus服务
运行该目录下的install-nexus.bat文件(右击以管理员身份运行),该窗口会一闪而过,然后运行start-nexus.bat文件,等该文件运行窗口关闭后,在浏览器访问http://127.0.0.1:8081/nexus/。就会看到该欢迎页面。
3、创建 * 仓库
然后点击右上角的log in 进行登录,默认用户名:admin,密码:admin123。登陆后在右边选项卡 Views/Repositories下选择 Repositories就可以看到所有仓库,该地方不做过多的介绍,只介绍如何进行 * 仓库配置。
选择上方的add按钮,然后选择hosted Repositiry创建一个本机仓库,填入仓库相应的信息即可创建成功。
4、配置 * 信息
和本地仓库一样, * 仓库也需要在setting.xml中进行配置,这样才能够访问。
在setting.xml 文件中找到标签,在其中插入如下代码,其中的id,name标签内的内容必须要和在nexus中创建仓库是所填的仓库ID和仓库名称一致,URL标签内的内容就是该仓库创建后后面显示的地址。
<profile>
<id>localRepository</id>
<repositories>
<repository>
<id>myRepository</id>
<name>myRepository</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/myRepository/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
然后还必须要激活改配置,在setting.xml文件的标签内插入如下代码段。
<activeProfile>localRepository</activeProfile>
配置分发构建到 * 的验证,在setting.xml文件的标签内插入如下代码段
<server>
<id>myRepo</id>
<username>admin</username>
<password>admin123</password>
</server>
至此 * 仓库就配置成功了。
中央仓库的配置
配置中央仓库和配置 * 仓库类似:
1、在setting.xml 文件中找到标签,在其中插入如下代码,其中的id,name标签内的内容必须要和在nexus中创建仓库是所填的仓库ID和仓库名称一致,URL标签内的内容就是该仓库创建后后面显示的地址。
<profile>
<id>central</id>
<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
2、然后还必须要激活改配置,在setting.xml文件的标签内插入如下代码段。
<activeProfile>central</activeProfile>
三个仓库之间的关系
三者之间的关系是,当我们在项目中依赖一个jar包时,Maven程序会先去本地仓库中找,如果没找到就回去 * 找,如果还是没有,最后就回 * 仓库找。其过程如下图:
来源:https://blog.csdn.net/qq_25989401/article/details/120239783
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android中实现EditText密码显示隐藏的方法
![](https://img.aspxhome.com/file/2023/6/89506_0s.png)
Kotlin object的几种用法示例详解
![](https://img.aspxhome.com/file/2023/0/109200_0s.png)
JavaMail实现发送超文本(html)格式邮件的方法
Android开发5:应用程序窗口小部件App Widgets的实现(附demo)
![](https://img.aspxhome.com/file/2023/6/120096_0s.png)
Java使用组件编写窗口实现网上文件下载
![](https://img.aspxhome.com/file/2023/8/108438_0s.jpg)
ReentrantLock源码详解--公平锁、非公平锁
![](https://img.aspxhome.com/file/2023/1/69691_0s.png)
SpringCloud搭建netflix-eureka微服务集群的过程详解
![](https://img.aspxhome.com/file/2023/3/58293_0s.jpg)
java中ConcurrentHashMap的读操作为什么不需要加锁
![](https://img.aspxhome.com/file/2023/1/132181_0s.png)
c++ 函数指针相关总结
Android手动检查并申请权限方法
MyBatis实现多表联合查询resultType的返回值
Android数据类型之间相互转换系统介绍
redisson分布式限流RRateLimiter源码解析
![](https://img.aspxhome.com/file/2023/4/110924_0s.jpg)
函数指针的一些概念详解
详解java.lang.reflect.Modifier.isInterface()方法
JavaWeb中使用JavaMail实现发送邮件功能实例详解
![](https://img.aspxhome.com/file/2023/1/60821_0s.png)
SpringBoot如何使用Fastjson解析Json数据
![](https://img.aspxhome.com/file/2023/1/60041_0s.png)