I am using maven project in Eclipse, where I am not able to access classes under src/main/java in src/test/java class. I could use the classes in maven dependacies jars though. What am I missing ?
4 Answers
18
votes
I have found that sometimes this error appears and by simply going Project -> Clean...
the error will stop.
However if this does not work there is a blog with some more suggestions here
Updated 11/07/2017
The original link is no longer available, refer to web archive here
Or just have them all here..
- ‘Clean’ Your Eclipse Project: Go to Project > Clean in Eclipse [This seems to work for me]
- Refresh your project folder (right click on your project > refresh)
- Re-build your project
- Clean your builds (If using Ant or Maven – clean your builds)
- Recreate your project in Eclipse
- ‘Switch’ Workspace – then Switch back (Eg Change to Debug, then switch back to Java)
- Remove and re-add your JRE:
- Right Click on your project > properties
- Click on the Libraries tab
- Click on the JRE
- Click remove, then OK
- Repeat 1-3 again, but add the JRE again
1
votes
0
votes
Absolutely, one can do it..
First You need to navigate to Build Path-->Configure Build Path--> Source tab
then in the Source tab search/check [your Project Name]/src/main/java and change
"contains test sources" from No to Yes and save it.
This will resolved issue of import packages from "src/test/java" to "src/main/java" successfully