maven私服测试案例
私服测试
1、下载私服依赖jar包
- setting.xml配置
<mirrors>
<!-- 私服镜像地址 -->
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://119.3.41.127:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<!-- profile的id -->
<id>dev</id>
<repositories>
<repository>
<!-- 仓库id,repositories标签内可以配置多个仓库,但要保证id不重复 -->
<id>nexus</id>
<!-- 仓库地址,即nexus仓库组的地址 -->
<url>http://119.3.41.127:8081/nexus/content/groups/public/</url>
<!-- 是否下载releases构件 -->
<releases>
<enabled>true</enabled>
</releases>
<!-- 是否下载snapshots构件 -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库,maven的运行依赖插件也需要从私服下载 -->
<pluginRepository>
<!-- 插件仓库的id不允许重复,如果重复后边的配置会覆盖前边的配置 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://119.3.41.127:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
2、上传jar包到私服
-
setting.xml配置
<servers> <server> <id>nexus</id> <username>admin</username> <password>liutao990414</password> </server> </servers>
上传项目依赖配置
<distributionManagement> <repository> <id>nexus</id> <name>Nexus Release Repository</name> <url>http://119.3.41.127:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus</id> <name>Nexus Snapshot Repository</name> <url>http://119.3.41.127:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
依赖测试
<dependency>
<groupId>com.lt</groupId>
<artifactId>common2</artifactId>
<version>1.1.1-SNAPSHOT</version>
</dependency>