先说结论:
在遇到maven问题时,比如'dependencies.dependency.version' is missing或者pom.xml文件报错(语法没错)或者无法下载相应的jar包时,请记得清空local repository里的包,在重新Reimport
今天遇到一个比较奇怪的问题,代码下载好之后类报错,提示需要添加依赖,确定相关依赖是没有问题的,比较大的开源项目,在项目路径下执行mvn clean,报错如下
E:\work\sources\RuoYi>mvn clean
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-comp
iler-plugin is missing. @ line 96, column 21
[ERROR] 'modelVersion' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[u
nknown-version], C:\Users\Administrator\.m2\repository\org\springframework\boot\
spring-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.po
m, line 2, column 7
[ERROR] 'groupId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknow
n-version], C:\Users\Administrator\.m2\repository\org\springframework\boot\sprin
g-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.pom, li
ne 2, column 7
[ERROR] 'artifactId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unk
nown-version], C:\Users\Administrator\.m2\repository\org\springframework\boot\sp
ring-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.pom,
line 2, column 7
[ERROR] 'version' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknow
n-version], C:\Users\Administrator\.m2\repository\org\springframework\boot\sprin
g-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.pom, li
ne 2, column 7
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-context
-support:jar is missing. @ line 57, column 15
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-web:jar
is missing. @ line 63, column 15
[ERROR] 'dependencies.dependency.version' for mysql:mysql-connector-java:jar is
missing. @ line 76, column 21
[ERROR] 'dependencies.dependency.version' for javax.servlet:javax.servlet-api:ja
r is missing. @ line 81, column 20
[ERROR] 'dependencies.dependency.version' for org.slf4j:slf4j-api:jar is missing
. @ line 87, column 15
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.ruoyi:ruoyi:3.2 (E:\work\sources\RuoYi\pom.xml) has 9
errors
[ERROR] 'modelVersion' is missing. @ [unknown-group-id]:[unknown-artifact-id
]:[unknown-version], C:\Users\Administrator\.m2\repository\org\springframework\b
oot\spring-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEAS
E.pom, line 2, column 7
[ERROR] 'groupId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[un
known-version], C:\Users\Administrator\.m2\repository\org\springframework\boot\s
pring-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.pom
, line 2, column 7
[ERROR] 'artifactId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:
[unknown-version], C:\Users\Administrator\.m2\repository\org\springframework\boo
t\spring-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.
pom, line 2, column 7
[ERROR] 'version' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[un
known-version], C:\Users\Administrator\.m2\repository\org\springframework\boot\s
pring-boot-dependencies\2.1.1.RELEASE\spring-boot-dependencies-2.1.1.RELEASE.pom
, line 2, column 7
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-con
text-support:jar is missing. @ line 57, column 15
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-web
:jar is missing. @ line 63, column 15
[ERROR] 'dependencies.dependency.version' for mysql:mysql-connector-java:jar
is missing. @ line 76, column 21
[ERROR] 'dependencies.dependency.version' for javax.servlet:javax.servlet-ap
i:jar is missing. @ line 81, column 20
[ERROR] 'dependencies.dependency.version' for org.slf4j:slf4j-api:jar is mis
sing. @ line 87, column 15
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildin
gException
一直找不到问题,直到在网上看到说需要删除cache再重新Reimport,才解决该问题,可能之前在下载包的时候中断,导致无法更新。