Reputation: 1707
After running Maven - clean, I see sub folders in my M2_REPO folder. junit.jar was created in M2_REPO/junit/junit/4.11/ alone with some other files. Because of this sub folder structure, eclipse is not able to recognize the junit.jar file. What am I missing?
Upvotes: 0
Views: 301
Reputation: 3469
That is the path of the local M2 repository and the sub-folder structure is exactly how it should look. Make sure that you import the project in eclipse as a maven project by doing
File -> Import -> Maven -> Existing maven project
Upvotes: 1
Reputation: 70999
You're looking in the wrong directory. Eclipse shouldn't read the jars directly from this directory, it is the local cache of what maven manages.
The pom.xml is where you should put your dependencies, and eclipse will then use the maven libraries to get the required jar file, put it on the build path, and possibly cache it in the directory you are looking at.
Note that if you want the junit jar file for testing purposes, the typical file in src/main/java will not see it, because testing source code goes in src/test/java.
This means that maven provides (through the libraries) (at least) two classpaths. One for typical compilation and one for test compilation and execution. Adding in a <dependency> tag section puts it on the compilation and run paths; but, to make it "test only" you need a nested <scope> tag.
Upvotes: 2
Reputation: 2883
Maven correctly is creating those directories the first time it tries to acquire those artifacts.
For integrating maven and eclipse, try running mvn eclipse:eclipse
This should enable eclipse to see the jars maven has downloaded.
Upvotes: 1