命令行下载jar
mvn dependency:get -DremoteRepositories=http://192.129.123.233:8081/repository/public/ -DgroupId=jfqqq.test.com -DartifactId=data-test -Dversion=1.0.3-SNAPSHOT
基础知识
mirror中配置的库,默认只支持release库的拉取,snapshot是不支持的
所以如果想要拉取快照库,就需要给指定的库开启快照设置,如下:
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.9.111.111:8081/repository/jfqqqq-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
1.1 上面的这个配置可以写到项目的pom文件中,直接在<project>标签的根目录加上即可,如:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">
<modelVersion>1.1.1</modelVersion>
<groupId>com.jfqqqq.test</groupId>
<artifactId>jfqqqtest</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.7</version>
</dependency>
...
</dependencies>
<properties>
...
</properties>
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.9.111.111:8081/repository/jfqqqq-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
1.2 或者配置到settings中,在settings中就需要在profiles里配:
<profiles>
<profile>
<id>myProfile</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.9.111.111:8081/repository/jfqqqq-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>myProfile</activeProfile><!-- 注意值要与上面的<id>中的一致 -->
</activeProfiles>
当然,这样配置后,mirror中就不需要再配了(一般需求下)
:
部署jar到私服
settings文件,基础知识见上面的即可。
然后是项目中的pom.xml,先上实例:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jfqqq.test</artifactId>
<groupId>jfqqqq.test.com</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jfqqq.test.one</artifactId>
<version>0.0.2-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
...
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>tdtNexus-snapshot</id>
<name>Nexus Snapshot</name>
<url>http://192.168.100.412:8080/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>tdtNexus-releases</id>
<name>Nexus Snapshot</name>
<url>http://192.168.100.412:8080/repository/maven-releases/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
重点位置
1. <version/>标签中需要放置的内容中,如果是“-SHNAPSHAOT”结尾则会部署到snapshot库下,如果是“-RELEASE”则是放在release库下。
2. <distributionManagement />标签中配置SNAPSHOT和RELEASE库的地址,其中<repository />是release库,<snapshotRepository />是snapShot库。库的密码什么的见上面的基础知识即可。
3. <build/>标签中获用于配置将源代码打包,这时候就也会把源代码部署上去
补充:<distributionManagement/>标签中的两个maven地址,可以通过自己打开自己的maven私服,找到对应的服务(如下图),点击进去查看地址即可: