Reputation: 280
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 ?
Upvotes: 12
Views: 18223
Reputation: 1042
In my case, it was happening because my IntelliJ Idea was configured for a different JDK version and my terminal was referring to a different JDK version. Due to this whenever I run Maven clean from the terminal, and then try to run tests via IDE, it gives this error.
Upvotes: 0
Reputation: 81
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
Upvotes: 0
Reputation: 1050
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..
Upvotes: 19
Reputation: 20520
You just need to import
them. Eclipse should help you with this: if you try to use the class names, it'll suggest where to import from.
The test classes are a separate package, so the classes will need to be declared public
.
Upvotes: 1