上传jar到远程仓库

本文介绍了如何通过修改Maven的settings.xml文件和项目pom.xml文件,配置并使用IDEA的Maven部署功能,将jar包上传到Nexus远程仓库。此外,还提供了一个命令行上传的备选方案。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值