1.首先修改下载的nexus文件夹下面的 bin/jsw/conf/wrapper.conf文件,用文本编辑器打开,找到下图所示的位置:
这个地方修改为java的绝对路径。
2.修改maven的setting.xml文件,为了使请求下载的jar包从我们的私服去取,在<profiles>..</profiles>
添加下面的内容
<profile>
<id>nexusProfile</id> //可以随便
<repositories>
<repository>
<id>nexus</id>
<name>nexus repo</name>
<url>http://172.21.15.82:8081/nexus/content/groups/public/</url>
//指定的nexus的私服的路径
<releases>
<enabled>true</enabled>//可以下载release版本的依赖,默认就是true
</releases>
<snapshots>
<enabled>true</enabled>//可以下载snapshots的依赖,默认是false
</snapshots>
</repository>
</repositories>
</profile>
<activeProfiles>
<activeProfile>nexusProfile</activeProfile>//激活当前nexus私服的配置
</activeProfiles>
3.现在呢,如果私服关闭,我们的请求还是可以去中央工厂下载依赖包的,而现在如果我们只想她从我们的私服中下载,也就是说,私服如果没有则就没有,我们需要在setting.xml的<mirrors>..</mirrors>
添加如下内容:
<mirror>
<id>nexusMirror</id>
<mirrorOf>*</mirrorOf>//指的是所有工厂都要访问下面的url
<name>Human Readable Name for this Mirror.</name>
<url>http://172.21.15.82:8081/nexus/content/groups/public/</url>//私服url
</mirror>
其实这样设置了第二条中设置的私服就不起作用了,因为所有的工厂都会去私服寻找,但这样有个不好的地方,那就是私服如果关闭,那么就不能下载依赖包了
4.如何上传你的jar包到maven私服中供其他人来下载呢?,首先需要在setting.xml文件中添加用户,找到<servers>...</servers>
里面添加如下的内容:
<server>
<id>user-release</id> //指示一下这里可以发布user-release的内容
<username>deployment</username> //默认的用户名跟密码
<password>deployment123</password>
</server>
<server>
<id>user-snapshots</id> //指示一下这里可以发布user-snapshots的内容
<username>deployment</username> //默认的用户名跟密码
<password>deployment123</password>
</server>
接下来在项目的pom文件中设置如下: