D:\apache-maven-3.5.0\conf下的settings.xml配置如下:
阿里的共享仓库:
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
本地私建的仓库:
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.3.141/nexus/content/groups/public/</url>
</mirror>
涉及到的软件有:
Nexus Repository Manager OSS可以免费使用
apache-maven-3.6.0-bin.zip
nexus-3.21.2-03-win64.zip
如何搭建本地仓库,可以搜索: 使用nexus搭建maven私服教程详解
尝试创建第一个Maven项目,CMD窗口执行下面命令:
mvn archetype:generate “-DgroupId=com.companyname.demo” “-DartifactId=unit1Demo1-FirstMvn” “-DarchetypeArtifactId=maven-archetype-quickstart” “-DinteractiveMode=false”
源码编译: mvn compile
测试: mvn test
代码打包: mvn install
生成站点信息:
1、打开工程的pom.xml文件,在最外层的project标签内添加下方代码
2、CMD窗口里执行命令:mvn site
把本地jar上传到远程Maven仓库:
cmd命令窗口里:
mvn –version 查看mvn是否正确安装
如果没有,先安装maven后,在系统变量里添加:
MAVEN_HOME
E:\apache-maven-3.5.0 – maven的安装目录
E:
\>mvn deploy:deploy-file -DgroupId=com.xxxxxx -DartifactId=sgjdbc_1130 -Dversion=NX20230323 -Dpackaging=jar -Dfile=E:\Delete\NX20230323\sgjdbc_1130-NX20230323.jar -DpomFile=E:\Delete\NX20230323\sgjdbc_1130-NX20230323.pom -Durl=http://192.168.3.141/nexus/content/groups/public/ -DrepositoryId=xxxxxx-Releases
其中:安装的jar和pom 拷贝至非本地仓库位置 E:\Delete\NX20230323
-DrepositoryId=xxxxxx-Releases 为maven conf/settings.xml配置的server名称