1.修改maven的配置文件settings.xml
| $>vi ~/Soft/maven/conf/settings.xml |
2.修改内容:
| <server>
<id>nexus-releases</id>
<username>nexususer</username>
<password>nexuspassword</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>nexususer</username>
<password>nexuspassword</password>
</server> |
3.添加要上传jar包的项目中的pom.xml文件,添加内容为:
| <distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>正确的远程仓库的数据地址</url>
eq:https:/repository/data-releases/
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshots Repository</name>
<url>
正确的远程仓库的镜像地址
eq:https:/repository/data-snapshots/
</url>
</snapshotRepository>
</distributionManagement> |
4. 添加相关依赖:
| <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> |
5.使用idea上传找到项目工具栏中的Maven Project选项,找到并点击deploy选项

6.等待执行完成,刷新nexus,上传成功
补充一个命令行上传命令:
| mvn deploy:deploy-file -DgroupId=com.mfw -DartifactId=server-sdk -Dversion=3.0 -Dpackaging=jar -Dfile=/Users/liliguo/IdeaProjects/server-event-sdk/target/server-sdk-3.0.jar -DrepositoryId=nexus-releases -Durl=https://nexus.mfwdev.com/repository/data-releases -e |