Cannot import java classes under src / main / java in src / test / java in eclipse

I am using the maven project in Eclipse, where I cannot access the classes in src / main / java in the src / test / java class. However, I could use classes in maven databases. What am I missing?

+5
source share
3 answers

I found that sometimes this error appears and, simply by going to Project -> Clean... , the error stops.

However, if this does not work, there is a blog with a few suggestions here

Updated 07/11/2017

The source link is no longer available; refer to the web archive here

Or just all of them here.

  • 'Clean up the Eclipse project: go to Project> Clean in Eclipse [This seems to work for me]
  • Update the project folder (right click on your project> update)
  • Restore your project
  • Clean your builds (if using Ant or Maven - clean your builds)
  • Create a new project in Eclipse
  • 'Switch workspace - then switch (for example, "Change to debug", then return to Java)
  • Remove and re-add the JRE:
    • Right click on your project> properties
    • Go to the Libraries tab
    • Click JRE
    • Click Delete, then OK.
    • Repeat 1-3 again, but add the JRE again.
+8
source

You just need to import them. Eclipse should help you with this: if you try to use class names, it will suggest where to import it from.

Test classes are a separate package, so classes must be declared public .

+1
source

Project → Clear

enough for me to work

-1
source

Source: https://habr.com/ru/post/1208806/


All Articles