要先定位到jar所在的目录执行
maven 上传jar到私服 并指定seting.xml文件
java
mvn deploy:deploy-file -Dmaven.test.skip=true -Dfile=gbasedbtjdbc_3.5.1_3X2_1.jar -DgroupId=com.gbase -DartifactId=gbasedbtjdbc -Dversion=3.5.1 -Dpackaging=jar -Durl=http://127.0.0.1:8081/repository/singon-releases/ -DrepositoryId=singon-releases -s D:\tools\develop\java\maven-repository\settings.xml
maven 上传jar到本地仓库
java
mvn install:install-file -Dfile=gbasedbtjdbc_3.5.1_3X2_1.jar -DgroupId=com.gbase -DartifactId=gbasedbtjdbc -Dversion=3.5.1 -Dpackaging=jar
注意maven安装目录下的seting.xml配置
XML
<servers>
<server>
<id>singon-snapshots</id>
<username>xgzl</username>
<password>xgzl@1234</password>
</server>
<server>
<id>singon</id>
<username>xgzl</username>
<password>xgzl@1234</password>
</server>
<server>
<id>nexus</id>
<username>singon</username>
<password>singon</password>
</server>
<server>
<id>singon-releases</id>
<username>singon</username>
<password>singon</password>
</server>
</servers>
<mirrors>
<!-- 阿里云镜像 -->
<mirror>
<id>aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Aliyun Maven Central Mirror</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
<!-- 250服务器仓库 -->
<mirror>
<id>singon-250</id>
<mirrorOf>central,!aliyun</mirrorOf>
<name>Singon Repository 250</name>
<url>http://ip:port/repository/singon-group/</url>
</mirror>
<mirror>
<id>singon-releases</id>
<mirrorOf>central,!aliyun,!singon-250</mirrorOf>
<name>Singon Repository 250</name>
<url>http://ip:port/repository/singon-releases/</url>
</mirror>
</mirrors>
当需要从私服中下载jar时,pom.xml文件需要增加
XML
<dependency>
<groupId>com.gbase</groupId>
<artifactId>gbasedbtjdbc</artifactId>
<version>3.5.1</version>
</dependency>
<repositories>
<repository>
<id>singon-releases</id>
<url>http://ip:port/repository/singon-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Maven 通过在 pom.xml
文件中定义的仓库列表和依赖项来识别从哪个仓库下载特定的依赖。当 Maven 构建项目时,它会按照配置文件中定义的顺序检查每个仓库,直到找到所需的依赖项为止。