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 ,将相关参数加上