idea maven依赖爆红各种解决办法

本文介绍了如何清理Windows和Mac系统下的Maven本地仓库中的垃圾文件,包括删除.lastUpdated、_remote.repositories和_maven.repositories文件的步骤。同时,针对Maven库中存在jar包但无法正常依赖的问题,提供了导入jar包到Maven库的方法,并详细解释了各参数含义。此外,还分享了在导入过程中可能遇到的错误及解决方法,如缺少packaging参数导致的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.maven库里有垃圾文件

windows:进入maven路径下执行以下步骤

  • 删除*.lastUpdated文件

    for /r %i in (*.lastUpdated) do del %i
    
  • 删除*_remote.repositories文件

    for /r %i in (*_remote.repositories) do del %i
    
  • 删除*_maven.repositories文件

    for /r %i in (*_maven.repositories) do del %i
    

mac:进入本地仓库路径下执行以下步骤

  • 删除*.lastUpdated文件

    find . -name "*.lastUpdated" | xargs rm -fr
    
  • 删除*_remote.repositories文件

    find . -name "*remote.repositories" | xargs rm -fr
    
  • 删除*_maven.repositories文件

    find . -name "*_maven.repositories" | xargs rm -fr
    

2.maven库里有对应jar包,但是依赖不到,依旧在下载

原因:jar包没有导入进maven库
导入方法:

mvn install:install-file -DgroupId=org.trafodion -DartifactId=jdbcT4 -Dversion=2.4.0 -Dpackaging=jar -Dfile=D:\asianinfo\apache-maven-3.2.1\jdbcT4-2.4.0.jar

属性解释:

  • Dfile:包的本地真实地址
  • DgroupId:pom.xml中groupId
  • DartifactId:pom.xml中artifactId
  • Dversion:pom.xml中2.4.0
  • Dpackaging:jar或war,包的后缀名

踩坑记
1.jar包导入maven库报错:Artifact is already in the local repository

  • 原因:直接把jar包放在了库里面对应的位置
  • 解决方法:将jar包放在其他位置,这样mvn就可以根据命令将Jar包导入到对应的位置

2.报错如下图

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project standalone-pom: The artifact information is incomplete or not valid:
[ERROR] [0]  'packaging' is missing.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

  • 原因:-Dpackaging 不小心删掉了
  • 解决方法:检查-Dpackaging ,将相关参数加上
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值