Nexus添加的包怎么就下载不下来?

本文介绍了解决Nexus中新增依赖包无法被Maven项目识别的问题,通过使用-maven参数-U强制检查更新快照,确保项目能及时获取最新上传的包。同时,提醒上传时需勾选生产POM文件。

Nexus添加的包怎么就下载不下来?

最近在本地Nexus中添加了一个外部依赖包,通过Nexus后台可以查看,通过URL也可以访问,可是本地开发环境就是说找不到。

错误如下:

[ERROR] Failed to execute goal on project enterprise-server: Could not resolve dependencies for project com.thgy:enterprise-server:jar:1.0-SNAPSHOT: Failure to find net.ipmarker:IPMarker_DevAPI_JavaSDK:jar:2.0 in http://nexus.xxxx.xxx/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]

通过上面发现,问题在于,maven并没有从nexus上寻找新包,原因就是时间没有到(而包是我刚上传的)。

后面发现maven有一个参数:

 -U,--update-snapshots                  Forces a check for missing releases and updated snapshots on

通过命令行:

mvn -U compile

就可以把项目需要的包下载下来了。

另外:
通过管理后台上传时,注意勾选生产POM文件。

在这里插入图片描述

解决maven项目无法下载jar问题,可尝试以下方法: 1. **检查maven和IDEA配置**:在maven解压下conf文件夹中setting.xml文件里配置本地仓库地址,示例如下: ```xml <localRepository>D:othermaven_repository</localRepository> ``` maven下载地址:最新版为http://maven.apache.org/download.cgi ,其它版本可访问https://mirrors.bfsu.edu.cn/apache/maven/ [^1]。 2. **确认依赖坐标配置**:需保证在项目pom.xml文件中正确配置依赖坐标,若依赖坐标错误会导致无法下载jar。示例pom.xml文件内容如下: ```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- 坐标:唯一值,在互联网中唯一标识一个项目的信息 --> <groupId>公司域名的倒写</groupId> <artifactId>自定义项目名称</artifactId> <version>自定版本号</version> <!-- 属性配置,这里是配置编译的JDK编译和运行版本 --> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <!-- 依赖:java代码中import使用某些时,需要在这里声明 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.9</version> </dependency> </dependencies> </project> ``` [^2] 3. **配置镜像**:可将以下代码添加到相应位置来配置镜像,以阿里云镜像为例: ```xml <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> ``` 或者在pom.xml中右键选择maven打开settings.xml,添加如下镜像配置: ```xml <mirror> <id>nexus-alimaven</id> <mirrorOf>*,!jeecg,,!jeecg-snapshots</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> ``` [^3][^4] 4. **删除本地jar并重新下载**:可删除本地所有的jar,然后重新下载 [^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值