eclipse 创建maven 项目 pox.xml 报错 解决方案 详细

1、右键点击project -> Maven - Update Dependencies 无效  注意选择 force update of snapshots/ releases

2、找到仓库,看是不是下的有 .lastUpdated 文件 , 是因为当下载网络上的jar包 网络不通 中途中断 会产生.lastUpdated,maven就不在从网上下载jar包了       ------------- 删除: 改文件名为 bat 批处理, 双击即可

windows:

@echo off
rem create by sunhao([email protected])
rem crazy coder
  
rem 这里写你的仓库路径
set REPOSITORY_PATH=E:\MvnRepository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    del /s /q %%i
)
rem 搜索完毕
pause

mac/linux:

# 这里写你的仓库路径

REPOSITORY_PATH=~/Documents/tools/apache-maven-3.0.3/repository

echo 正在搜索...

find $REPOSITORY_PATH -name "*lastUpdated*" | xargs rm -fr

echo 搜索完

扫描二维码关注公众号,回复: 2822115 查看本文章

3、添加阿里云maven仓库,点击Window下的Preferences,找到User Settings选项

添加以下代码:

<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

再重复第一步,如果还是无效:

4、重新下载所有未下载成功的maven包 (清空  .lastUpdated 文件)
在Eclipse菜单下选择Run--run configurations ,在打开的窗口新建一个maven配置

然后选择要更新maven库的工程,在Goals栏输入 clean install -U  

然后点击run,将会重新下载所有未下载成功的包 

更新还是无效

5、 手动将jar包放到maven仓库中,进入仓库后,搜索下载失败的jar包存放位置,粘贴进去

maven 公共库: http://mvnrepository.com/

寻找要下载的 jar 包  复制下载地址

复制到 pox.xml dos 进入到这个工程的 pox.xml 路径, mvn install 

然后 ,第一步操作

猜你喜欢

转载自blog.csdn.net/weixin_42178492/article/details/81133315