简体   繁体   中英

Eclipse not recognizing imports in same project

From time to time, Eclipse (Indigo) complains that certain classes in my projects cannot be resolved to a type . Even it shows the class in popup list, clicking import (see image) does not add the import statement! Even if I add it manually, it doesn't recognize it (and underlines the import package).

  • This happens only in certain projects.
  • Unresolved types are in the same project! (not in other dependencies)
  • cleaning the project does resolve this, but only temporarily.
  • My application consists of multi-module maven based projects.
  • All projects are maven-based.

Not recognizing imports

右键单击您的项目名称 -> Maven -> 更新项目

对于那些不使用 Maven 的人来说,简单地删除项目(并可能重新克隆它)对我来说可靠地工作。

This just happened to be in Eclipse Neon.2 (2016 release) on a non-Maven project. Refreshing / updating the project did not help, but I was able to fix this without recreating the project:

  1. Go to Properties → Build Path → Source
  2. Remove all source folders in the build path, click Apply.
  3. Add them all back, click Apply.

Right click on the project -> Maven -> Update Project...

Check (Force Update of Snapshots/Releases)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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