推荐通过maven配置,即第一种
通过maven上传
maven setting
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>maven-public</id>
<name>maven-public</name>
<url>http://192.168.1.2:8081/repository/maven-public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>maven-public</id>
<repositories>
<repository>
<id>nexus-releases</id> <!--正式仓库id-->
<!--name随便-->
<name>Nexus Release Snapshot Repository</name>
<!--地址是nexus中repository(Releases/Snapshots)中对应的地址-->
<url>http://192.168.1.2:8081/repository/maven-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-snapshots</id>
<url>http://192.168.1.2:8081/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<updatePolicy>always</updatePolicy>
</repository>
</repositories>
<pluginRepositories> <!--插件仓库地址,各节点的含义和上面是一样的-->
<pluginRepository>
<id>nexus-releases</id>
<name>Nexus Release Snapshot Repository</name>
<url>http://192.168.1.2:8081/repository/maven-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>nexus-snapshots</id>
<url>http://192.168.1.2:8081/repository/maven-snapshots/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<updatePolicy>always</updatePolicy>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!--激活配置-->
<activeProfiles>
<activeProfile>maven-public</activeProfile> <!--profile下的id-->
</activeProfiles>
</settings>
父pom
<?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>4.0.0</modelVersion>
<groupId>com.wd.cloud</groupId>
<artifactId>api-root</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>api-root</name>
<description>微服务根POM</description>
<modules>
<module>api-feign</module><!--内部互调接口定义-->
<module>api-gateway</module><!--api网关-->
<module>config-server</module><!--配置中心-->
<module>discovery</module><!--服务注册中心-->
<module>auth-server</module><!--鉴权服务-->
<module>doc-delivery</module><!--文献传递服务-->
<module>commons</module><!--提取的公共方法和类-->
</modules>
<distributionManagement>
<!-- 两个ID必须与 setting.xml中的<server><id>nexus-releases</id></server>保持一致-->
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.1.2:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.1.2:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
common 类pom
<build>
<plugins>
<!--避免没有main报错-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!--不上传到私服-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
命令行方式
mvn deploy:deploy-file \
-Dfile=C:\Users\madman\Desktop\alipay-sdk-java20161121110022.jar \
-Durl=http://192.168.1.142:8081/nexus/content/repositories/snapshots/ \
-DrepositoryId=nexus-snapshots \
-DpomFile=pom.xml
直接上传第三方jar包
有些时候,我们只有一个单独jar包,怎么上传呢?
参考:https://blog.csdn.net/Alice_qixin/article/details/78390192
1,登录web页面 http://192.168..:**/nexus/ 点击右上角登录。
2、找到第三方jar包目录
3、上传jar包
4、上传后查看结果