文章目录
第一步、pom文件中要有deploy插件
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</build>
第二步、要配置想要上传jar包到的目的maven仓库
<distributionManagement>
<repository>
<id>mycompany-nexus-releases</id>
<url>http://192.168.12.12:9081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>mycompany-nexus-snapshots</id>
<url>http://192.168.12.12:9081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
第三步、要在idea中自定义apache maven的setting.xml
示例代码:
<?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>
<pluginGroup>com.spotify</pluginGroup>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>mycompany-nexus-releases</id>
<username>username</username>
<password>password</password>
</server>
<server>
<id>mycompany-nexus-snapshots</id>
<username>username</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- 配置 Sonar Host地址,默认:http://localhost:9000 -->
<sonar.host.url>
http://192.168.2.182:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
</settings>
第四步、pom与setting.xml里的id、用户名、密码对应关系要一致
mycompany-nexus-releases
和
mycompany-nexus-snapshots