私服:是一种特殊的远程仓库,它是架设在局域网内的仓库
需要jar包时,从私服上找,如果没有,私服从中央仓库上下,中央仓库除版权jar包以外,都有,下到私服上,由私服返回,如果有,直接由私服返回。
配置私服
将nexus-2.1.2.war复制到服务器上,例如:tomcat/webapps目录下(哈哈哈。。。。),启动服务器(tomcat),nexus-2.1.2.war自动解压。
安装好之后可以访问:
localhost:8080/nexus-2.1.2
登陆 用户名admin 密码admin123
配置:
配置所有构建均从私服下载,在本地settin.xml中配置,url为public仓库的地址
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.1.100:8000/nexus/content/groups/public</url>
</mirror>
</mirrors>
在配置profiles
<profiles>
<profile>
<id>nexus</id>
<!--所有请求均通过镜像 -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
部署构建到Nexus,包含Release和Snapshot,在项目根目录中pom.xml(父工程)中配置:
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name> <url>http://localhost:8000/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name> <url>http://localhost:8000/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Nexus的访问权限控制,在本地setting.xml中配置如下:
<!-- 设置发布时的用户名 -->
<servers>
<server>
<id> releases </id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id> snapshots </id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>