Reputation: 21
I am just starting out with Maven. Is there any way to get maven dependencies to be added to the Eclipse project's build path? As of right now, my project is full of red x's due to Eclipse not being able to include some external class from one of these dependencies.
Upvotes: 2
Views: 3316
Reputation: 13420
Save yourself a ton of hassle and get the M2Eclipse plugin. The plugin will handle all of the project setup for you and you don't have to worry about doing the mvn eclipse:eclipse
commands.
http://www.sonatype.org/m2eclipse/
Upvotes: 1
Reputation: 301
First you need to setup you M2_REPO variable. This is a class path variable that tells eclipse where your designated maven repository is located. You can setup M2_REPO by running the following command in your workspace.
mvn -Declipse.workspace="replace with your Eclipse Workspace" eclipse:configure-workspace
Next make sure that your project has a maven fact applied by running the following command
mvn eclipse:eclipse
in the workspace of your project. run
mvn clean package
just for good measure to make sure all your dependencies are resolved and available before restarting eclipse.
Once you restart eclipse again and bring your project up your issues should be resolved.
You should look up more information about these 2 commands and how to use them effectively.
Upvotes: 1
Reputation: 2234
have you executed
mvn eclipse:configure-workspace -Declipse.workspace=/path/to/workspace
?
You need to execute it so maven set the M2_REPO
path to eclipse. Or you can set it manually.
Remenber to restart eclipse after you do so :P
Upvotes: 0