Eclipse配置Maven私服
Eclipse配置Maven私服
前言:
搭建Maven私有仓库的主要目的,是为了在团队多人开发时,只要内网的私有仓库有下载过依赖的jar包,就直接从私有仓库获取,不再通过外网的中央仓库。如果私服上面没有,就通过私服上面的索引到中央仓库中缓存到私服中。
配置方式:
Eclipse配置Maven私服有两种,一种是在pom.xml里面配置,只针对pom所在的工程;另一种是在Eclipse安装目录中的setting.xml中配置,这是针对Eclipse中所有工程;
一、配置私服的位置(从私服中下载jar);
1、 pom.xml中配置:
在pom.xml中的<project>中加入如下配置
1. <repositories>
2. <repository>
3. <id>nexus</id>
4. <name>nexus</name>
5. <url>http://192.168.100.52:8081/nexus/content/groups/public/</url>
6. <releases>
7. <enabled>true</enabled>
8. </releases>
9. <snapshots>
10. <enabled>true</enabled>
11. </snapshots>
12. </repository>
13. </repositories>
url指向本地私服的仓库组,并启用了releases库(稳定版本库)以及snapshots(开发版本库);其实我们的仓库组中除了包含了这两个库之外还包含了第三方库(3rd parth)以及中央库(central);
2、setting.xml中配置:
setting中配置要比pom麻烦多一点,不过毕竟人家是针对eclipse中的所有工程:
先在<servers>标签中添加私服的权限
14. <server>
15. <id>nexus-releases</id>
16. <username>admin</username>
17. <password>admin123</password>
18. </server>
19. <server>
20. <id>nexus-snapshots</id>
21. <username>admin</username>
22. <password>admin123</password>
23. </server>
这里的权限是用于上传jar到私服的;
接下来继续在setting.xml找到<mirrors>标签,我们来配置一下私服的镜像:
24. <mirror>
25. <id>nexus-releases</id>
26. <mirrorOf>*</mirrorOf>
27. <url>http://192.168.100.52:8081/nexus/content/groups/public/</url>
28. </mirror>
29. <mirror>
30. <id>nexus-snapshots</id>
31. <mirrorOf>*</mirrorOf>
32. <url>http://192.168.100.52:8081/nexus/content/repositories/snapshots/</url>
33. </mirror>
这里的id与前面的权限的id其实……没什么关系。
接下来继续找到<profiles>标签,开始配置私服:
34. <profile>
35. <id>nexus</id>
36. <repositories>
37. <repository>
38. <id>nexus-releases</id>
39. <name>Nexus</name>
40. <url>http://nexus-releases</url> <!—这里要引入上面的镜像-->
41. <releases>
42. <enabled>true</enabled>
43. <updatePolicy>never</updatePolicy>
44. <checksumPolicy>warn</checksumPolicy>
45. </releases>
46. <snapshots>
47. <enabled>true</enabled>
48. </snapshots>
49. </repository>
50. <repository>
51. <id>nexus-snapshots</id>
52. <name>Nexus</name>
53. <url>http://nexus-snapshots</url> <!—同样引入上面的镜像-->
54. <releases>
55. <enabled>true</enabled>
56. <updatePolicy>never</updatePolicy>
57. <checksumPolicy>warn</checksumPolicy>
58. </releases>
59. <snapshots>
60. <enabled>true</enabled>
61. </snapshots>
62. </repository>
63. </repositories>
64. <pluginRepositories> <!—同样是插件的配置-->
65. <pluginRepository>
66. <id>nexus-releases</id>
67. <name>Nexus</name>
68. <url>http://nexus-releases</url> <!—同样引入上面的镜像-->
69. <snapshots>
70. <enabled>true</enabled>
71. <updatePolicy>never</updatePolicy>
72. <checksumPolicy>warn</checksumPolicy>
73. </snapshots>
74. <releases>
75. <enabled>true</enabled>
76. </releases>
77. </pluginRepository>
78. <pluginRepository>
79. <id>nexus-snapshots</id>
80. <name>Nexus</name>
81. <url>http://nexus-snapshots</url> <!—同样引入上面的镜像-->
82. <snapshots>
83. <enabled>true</enabled>
84. <updatePolicy>never</updatePolicy>
85. <checksumPolicy>warn</checksumPolicy>
86. </snapshots>
87. <releases>
88. <enabled>true</enabled>
89. </releases>
90. </pluginRepository>
91. </pluginRepositories>
92. </profile>
最后,根据配置id激活这些配置,
93. <activeProfiles>
94. <activeProfile>nexus</activeProfile>
95. </activeProfiles>
当然,如果你是新建一个setting.xml的话,要在eclipse里面更改setting.xml的路径,指向你新建的setting.xml
Window->Prederences ->Maven -> User Settings
二、上传jar到私服:
如果工程编译出的jar包要上传到私服,那就要在要上传的工程的pom.xml中的<project>下,增加
1. <distributionManagement>
2. <repository>
3. <id>nexus-releases</id>
4. <name>Nexus</name>
5. <url>http://192.168.100.52:8081/nexus/content/repositories/releases/</url>
6. </repository>
7. <snapshotRepository>
8. <id>nexus-snapshot</id>
9. <name>Nexus</name>
10. <url>http://192.168.100.52:8081/nexus/content/repositories/snapshots/</url>
11. </snapshotRepository>
12. </distributionManagement>
上传时,右键项目Run As->Run Configurations->Maven Build
注:deploy后面的-e可以省略
扩展:
1、设置Maven的本地缓存:
Maven的本地缓存一般默认都是在C盘,这就有点让人难以接受了,不过还好,可以在setting.xml中配置一下缓存的位置:
<localRepository>D:\maven</localRepository>
2、配置在eclipse中配置jdk:
可以在setting.xml中的可以配置一下默认的jdk版本,这样就不用每个项目都去指定jdk的版本了
14. <profile>
15. <id>jdk-1.8</id>
16. <activation>
17. <activeByDefault>true</activeByDefault>
18. <jdk>1.8</jdk>
19. </activation>
20. <properties>
21. <maven.compiler.source>1.8</maven.compiler.source>
22. <maven.compiler.target>1.8</maven.compiler.target>
23. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
24. </properties>
25. </profile>
Eclipse配置Maven私服的更多相关文章
- 【项目管理和构建】十分钟教程,eclipse配置maven + 创建maven项目(三)
[项目管理和构建]十分钟教程,eclipse配置maven + 创建maven项目(三) 上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合 ...
- eclipse配置maven + 创建maven项目(三)
上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合,并我们创建一个maven的项目. 准备工作 在eclipse配置maven之前需要我们做 ...
- Eclipse配置maven环境
一.什么是maven? Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个 ...
- Eclipse配置maven环境1
一.什么是maven? Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个 ...
- Eclipse 配置Maven
Eclipse 配置Maven 下载Maven 首先在官网下载Maven:http://maven.apache.org/download.cgi 下载后将其解压到相应的位置 配置Maven环境变量 ...
- Mac中Eclipse配置Maven开发环境
1.下载Maven tar.gz包 http://maven.apache.org/download.cgi 2.解压tar包 随便一个路径都行 3.配置环境变量 bash设置~/.bash_prof ...
- eclipse配置maven + 创建maven项目
登录|注册 努力+坚持,而且还很年轻 目录(?)[+] 在现实的企业中,以低成本.高效率.高质量的完成项目,不仅仅需要技术大牛,企业更加需要管理大牛,管理者只懂技术是远远不够的.当 ...
- Eclipse配置Maven开发环境
前言: 现在Eclipse版本越来越高.高版本的Eclipse甚至已经集成了Maven像是SpringSource的哪个版本.用习惯了Eclipse.在开发中还是不想更换掉自己的IDE.如此一来就又了 ...
- Eclipse 安装Maven以及Eclipse配置Maven
安装Maven 1 下载 Downloading Apache Maven 3.5.0 选择 2 解压 3 配置环境变量 新建变量名:MAVEN_HOME 变量值:D:\SoftwareInstal ...
随机推荐
- HDU 1788
必须MARK下:任何时候都要保持清醒头脑,不要被题目绕了.. 其实就是求最小公倍数. #include <iostream> #include <cstdio> #includ ...
- Java測试覆盖率工具----Cobertura,EclEmma
Cobertura 是一个与Junit集成的代码覆盖率測量工具 它是免费.开源的 它能够与Ant和Maven集成.也能够通过命令行调用 能够生成HTML或XML格式的报告 能够依照不同的标准对HTML ...
- 多线程的join和interrupt
你可以在一个线程1里添加线程2对象thread的join方法来让线程1处于等待的状态 ,同时也可以调用thread.interrupt()来打断等待状态,此处注意 interrupt应在线程1开启st ...
- 本地配置 Redis
1.下载 https://redis.io/ https://github.com/dmajkic/Redis/downloads 2. 2.cmd 运行: 3.切换到另外一个cmd : ok! 关于 ...
- CSDN的技术问题
说CSDN是国内最大最好的技术论坛.预计不会有人反对,可是...CSDN的人,如管理员懂技术吗? 假设您长期在CSDN混.您就会发现他们相当懂得......强奸技术!
- uiautomator中InteractionController学习笔记(8)
4.1版本号 InteractionController将用户的键盘事件注入到android系统中,与系统进行交互(电视为什么不能设计成可组装,屏幕多大自己决定,想 多大就多大) click(int, ...
- Cocos2d-x3.0 RenderTexture(三)
.h #include "cocos2d.h" #include "cocos-ext.h" #include "ui/CocosGUI.h" ...
- angularjs1-过滤器
<!DOCTYPE html> <html> <body> <header> <meta http-equiv="Content-Typ ...
- caffe mnist实例 --lenet_train_test.prototxt 网络配置详解
1.mnist实例 ##1.数据下载 获得mnist的数据包,在caffe根目录下执行./data/mnist/get_mnist.sh脚本. get_mnist.sh脚本先下载样本库并进行解压缩,得 ...
- Selenium启动不同浏览器
1.启动Chrome "webdriver.chrome.driver" System.setProperty("webdriver.chrome.driver" ...