1、下载nexus,启动nexus,在nexus目录\bin\jsw\windows-x86-32目录下启动nexus,或者安装nexus服务。
2、可以在nexus目录下的conf目录下修改nexus.properties修改一些参数,比如启动端口,nexus的工作目录等
3、在maven的setting.xml中的profiles下添加如下配置:
<profile> <id>nexus-public</id> <repositories> <repository> <id>nexus</id> <url>http://localhost:9090/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile>
4、激活profile,添加如下配置:
<activeProfiles> <activeProfile>nexus-public</activeProfile> </activeProfiles>
这样就ok了,当你在pom.xml文件添加依赖时,首先会去nexus中找,如果没有的话再去maven 中心仓库中下载,关于nexus的使用,大家自己可以上网找找资料学习一下。但是这样还会有一个问题,如果有人在完成这个项目之后给大家共享,就还需要以下步骤了:
1、在setting.xml文件中添加:
<!-- 构建发布是需要登录 --> <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>
2、在pom.xml中添加:
<!-- 构件发布管理 --> <distributionManagement> <!-- 代表release构件 --> <repository> <!-- 需要与setting.xml中的server中的id对应 --> <id>nexus-releases</id> <name>Nexus Release Repository</name> <!-- 发布的目标url --> <url>http://localhost:9090/nexus/content/repositories/releases/</url> </repository> <!-- 代表snapshots构件 --> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus snapshots Repository</name> <url>http://localhost:9090/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
这样就ok了,以上就是所有的maven的知识,其实我没有讲好,是因为我是在一天一口气写了这三篇文章,随后我会把这三篇文件优化一下,尤其是第二篇文章,我觉得太不详细了,有点简陋,里面的各个元素代表什么作用也没给大家讲,但是这方面的资料网上已经很多了,但是关于模块化的东西比较少。