1,搭建maven私服略。。。maven私服搭建
2,搭建本地仓库:
2.1,maven下载解压:
2.2,配置setting.xml文件
2.2.1,配置本地仓库地址:D:/application/maven/repository (小编本地仓库地址)
<localRepository>D:/application/maven/repository</localRepository>
2.2.2,配置jdk:(不是必须配置:如果不配做,创建maven项目时需要手动导入jdk或jre )
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
2.2.3,配置镜像:
<!--私服镜像-->
<mirror>
<id>local-nexus</id>
<name>localmaven</name>
<url>http://192.168.2.101:8081/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
2.2.4,配置私服构建(连接私服用的到 jar 等内容)
<!-- 私服配置:还要配置 -->
<profile>
<id>nexus-maven</id>
<repositories>
<repository>
<id>local-nexus</id>
<url>http://192.168.2.101:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
2.2.5,配置让私服构建生效
<!-- 私服:激活 id 为 profile 的 id-->
<activeProfiles>
<activeProfile>nexus-maven</activeProfile>
</activeProfiles>
3,如果只是下载私服jar,而不发布项目到maven私服,那么配置已经配置完成:
测试:随便找一个本地没有的jar进行测试
4,如果还需要发布项目到maven私服还需配置:
4.1,pom.xml文件中添加:(可以单个配置)
<!--正式版-->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.101:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
<!--快照版-->
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.101:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
4.2,setting.xml配置:
<!--私服配置:发布使用-->
<!--正式版-->
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<!--快照版-->
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
5,测试发布:
5.1, 右键项目——>run as ——>maven build——deploy
5.2,查看maven私服是否已经有了这个项目:
5.3,发布后其他模块开发人员就可以使用了:
只需要添加:
<dependency>
<groupId>dubbo-account-parent</groupId>
<artifactId>dubbo-account-parent11</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>