1、仓库类型
hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。比如公司的第二方库。
proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。
group:仓库组,用来合并多个hosted和proxy仓库。
2、版本类型
Releases稳定版本。
Snapshot快照版本.
3、搭建仓库
(1)、点击Repositories的Add按钮,选择Hosted Repository:
(2)、配置Hosted Repository
(3)、点击save,仓库就搭建成功了
4、使用私服仓库
(1)、maven的setting.xml文件配置。 注意:这里的id一定要和你项目中的私服地址id一模一样,如果这里的用户名密码写错了,会报错:401 ReasonPhrase: Unauthorized.。
(2)、pom.xml文件配置
(3)、发布到私服,maven项目使用命令:mvn clean deploy
。或者在idea的右边找到Maven Projects,点击Lifecycle中的deploy。
使用私服的插件:
<pluginRepositories>
<pluginRepository>
<id>maven-test</id>
<name>test</name>
<url>http://192.168.106.130:8085/nexus/content/repositories/maven-test/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
如果想本机所有的maven项目都使用私服的组件,可以在maven的设置文件settings.xml中添加属性,并激活:
<profiles>
<profile>
<id>nexusProfile</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.1.103:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!-- 激活 -->
<activeProfiles>
<activeProfile>nexusProfile</activeProfile>
</activeProfiles>