将包传内网的Nexus ,亲测可用

当你需要将本地的 JAR 文件上传到 Maven 仓库时,你需要使用 Maven 的 deploy 插件。下面是一个示例 Maven 配置文件 pom.xml,其中包含了配置 Maven deploy 插件的部分:

<project>
    <!-- 其他项目配置 -->

    <distributionManagement>
        <repository>
            <id>internal.repo</id> <!-- 仓库标识符,需要和 settings.xml 中配置的服务器 ID 匹配 -->
            <name>Internal Repository</name> <!-- 仓库名称 -->
            <url>http://your-nexus-server/repository/internal</url> <!-- 仓库地址 -->
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.0.0-M1</version>
                <configuration>
                    <skip>true</skip> <!-- 配置是否跳过部署 -->
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

需要注意的是,这个配置文件中的 <distributionManagement> 部分指定了部署目标的仓库信息,你需要根据你的实际情况修改 repository 标签下的 idnameurl

然后,你还需要在 Maven 的 settings.xml 文件中配置服务器的认证信息,以便能够上传文件到仓库。在 <servers> 部分添加如下配置:

<settings>
    <!-- 其他设置 -->

    <servers>
        <server>
            <id>internal.repo</id> <!-- 和 pom.xml 中 distributionManagement 中的 repository id 对应 -->
            <username>your-username</username> <!-- 你的 Nexus 用户名 -->
            <password>your-password</password> <!-- 你的 Nexus 密码 -->
        </server>
    </servers>


	<profile>
		<id>nexus-deployment</id>
		<properties>
			<altDeploymentRepository>internal.repo::default::http://172.30.30.2**:8081/repository/maven-releases/</altDeploymentRepository>
		</properties>
	</profile>
    <!-- 其他设置 -->
</settings>

在这个配置中,id 需要和 pom.xml 中的 <distributionManagement> 中指定的仓库 ID 匹配。usernamepassword 是你在 Nexus 中配置的用户名和密码。

配置好这两个文件后,你就可以使用 Maven 的命令将本地的 JAR 文件上传到 Maven 仓库了。具体命令是:

mvn deploy:deploy-file -DgroupId=your-group-id -DartifactId=your-artifact-id -Dversion=your-version -Dpackaging=jar -Dfile=/path/to/your/jar/file -Durl=http://your-nexus-server/repository/internal -DrepositoryId=internal.repo

请将命令中的 your-group-idyour-artifact-idyour-version 替换为你的 JAR 文件的 Maven 坐标信息,/path/to/your/jar/file 替换为你的 JAR 文件的路径,http://your-nexus-server/repository/internal 替换为你的 Nexus 仓库地址,internal.repo 替换为你在 settings.xml 中配置的服务器 ID。

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值