maven deploy到nexus后,无法注入依赖问题解决方案

本文详细介绍了如何在IntelliJ IDEA中使用Maven部署项目到私服,并解决引入依赖时遇到的cannotresolve错误。通过配置pom.xml和setting.xml,确保项目能够正确上传并被其他项目引用。

1、在idea中deploy

在项目的pom文件里配置


<distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Nexus Release Repository</name>
            <url>http://localhost:port/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://localhost:port/repository/maven-snapshots/</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>


关于私服maven的setting.xml配置自行百度,其中配置server的id与仓库的id需对应

上传完成示例:

到此部署到私服成功

2、引入依赖——报错 cannot resolve

解决方案:

setting.xml文件中配置Profile

<profiles>
    <profile>
		<id>nexus</id>
		<activation>
			<activeByDefault>true</activeByDefault>
		</activation>
		<repositories>
			<repository>
				<id>nexus</id>
				<name>Snapshots</name>
				<url>http://localhost:port/repository/maven-snapshots/</url>
				<snapshots>
					<enabled>true</enabled>
					<updatePolicy>daily</updatePolicy>
				</snapshots>
			</repository>
		</repositories>
	</profile>
	<profile>
		<id>nexus</id>
		<activation>
			<activeByDefault>false</activeByDefault>
		</activation>
		<repositories>
			<repository>
				<id>nexus</id>
				<name>Releases</name>
				<url>http://localhost:port/repository/maven-releases/</url>
				<snapshots>
					<enabled>true</enabled>
					<updatePolicy>daily</updatePolicy>
				</snapshots>
			</repository>
		</repositories>
	</profile> 
  </profiles>

也可在项目中配置相关属性(没有测试)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值