美文网首页
maven出现Cannot find the class fil

maven出现Cannot find the class fil

作者: nextliving | 来源:发表于2018-06-28 09:26 被阅读1次

今天遇到一个问题,eclipse中使用STS新建了一个maven项目,但是很多地方报错,具体错误信息是:

The project was not built since its build path is incomplete. Cannot find the class file for org.springframework.boot.SpringApplication. Fix the build path then try building this project

根据Spring start project fails in STS with spring boot 1.5.4中的解释,是因为maven解析依赖出了问题。

后来采用的解决方案是,在Terminal中进入项目目录,执行命令$ mvn dependency:purge-local-repository,终端输出内容如下

MacBookPro:mongodb-springdata-demo chenxin$ mvn dependency:purge-local-repository
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.41/kotlin-maven-plugin-1.2.41.pom
......
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.0.2/maven-dependency-plugin-3.0.2.jar (163 KB at 302.4 KB/sec)
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building mongodb-springdata-demo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.0.2:purge-local-repository (default-cli) @ mongodb-springdata-demo ---
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-velocity/1.1.7/plexus-velocity-1.1.7.pom
......
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-aop/5.0.7.RELEASE/spring-aop-5.0.7.RELEASE.jar (358 KB at 147.7 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:05 min
[INFO] Finished at: 2018-06-28T09:18:59+08:00
[INFO] Final Memory: 22M/219M
[INFO] ------------------------------------------------------------------------

可以看到下载了很多依赖的jar,之后在eclipse中项目右键->maven->update project,错误消失。如果还是解决不了,可以尝试删除maven本地仓库~/.m2/repository中的全部内容,然后在eclipse中项目右键->maven->update project

相关文章

网友评论

      本文标题:maven出现Cannot find the class fil

      本文链接:https://www.haomeiwen.com/subject/ezgwyftx.html