简体   繁体   English

Eclipse在Spring Boot项目中“无法解析类型”

[英]Eclipse "cannot resolve type" in spring boot project

I'm using the Spring Boot framework and Maven to develop an application in Eclipse IDE Mars.我正在使用 Spring Boot 框架和 Maven 在 Eclipse IDE Mars 中开发应用程序。 It was fine for a while and just happened today that some classes cannot be resolved by Eclipse.有一段时间没问题,今天刚发生,Eclipse 无法解析某些类。 The project still builds and works as expected but it is just quite annoying to see all the "errors" everywhere that aren't any.该项目仍然按预期构建和工作,但看到所有“错误”无处不在,这很烦人。

And yes, I've tried updating the project and restarted my IDE ;-)是的,我已经尝试更新项目并重新启动我的 IDE ;-)

I'd be happy about any advice.我很乐意接受任何建议。

Edit: Sorry, I know it's not really detailed, but it happens on every other class that I import from another project (no official import or anything).编辑:对不起,我知道它不是很详细,但是它发生在我从另一个项目导入的每个其他类中(没有官方导入或任何东西)。 This dependency is set in the pom file with correct groupID, artefactID and version.这个依赖是在 pom 文件中设置的,具有正确的 groupID、artefactID 和 version。 I'm using Java 1.8.我正在使用 Java 1.8。 Here's an extract of my pom.xml:这是我的 pom.xml 的摘录:

...
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.6.RELEASE</version>
    <relativePath/> 
</parent>

 <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.groupid</groupId>
        <artifactId>utilities</artifactId>
        <version>0.0.2-SNAPSHOT</version>
    </dependency> 
...

I get the same problem when I checkout another project and add the dependency in the pom.当我签出另一个项目并在 pom.xml 中添加依赖项时,我遇到了同样的问题。 Update meant right clicking in Eclipse on the project, select Maven and select "Update project".更新意味着在 Eclipse 中右键单击项目,选择 Maven 并选择“更新项目”。 I've tried Maven clean install as well.我也尝试过 Maven 全新安装。 As I said, the project builds fine and everything is working as desired.正如我所说,该项目构建良好,一切都按预期工作。 It just keeps displaying the errors.它只是不断显示错误。 Or is that an Eclipse bug?或者这是一个Eclipse错误?

As @Jiri Tousek said, you have to update (Maven Project Update or Maven clean install) all your projects that have dependencies to your own project.正如@Jiri Tousek 所说,您必须更新(Maven 项目更新或 Maven 全新安装)所有依赖于您自己的项目的项目。

It's just a pity that Eclipse isn't doing it or indicates the correct error...很遗憾 Eclipse 没有这样做或指示正确的错误......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM