Using maven with eclipse
As i first started using maven for my projects, I used to add the maven plugin to eclipse. The plugin makes you able to mark a project as "maven enabled". This adds the library maven dependencies to the classpath of the project so the dependency libraries can be visible to your classes.
As i moved further, I found a better way dealing with maven projects using eclipse; maven eclipse:clean and eclipse:eclipse goals.
the goals enables you to make all the configuration and settings through command line which is more powerful and stable. Actually i now never created a new project inside eclipse. It is better to created it outside using maven. Then through eclipse:eclipse u create eclipse project settings files that is ready to be imported to any running eclipse instance.
To put things into order. for better use of maven and eclipse:
Setup maven repo variable for the eclipse workspace
mvn -Declipse.workspace=D:\java\eclipse-workspace eclipse:add-maven-repo
Create your new maven project through command line
mvn archetype:create -DgroupId=com.mycompany -DartifactId=MyProject -DarchetypeArtifactId=maven-archetype-webapp -Dpackaging=war -Dgeneratepom=true
Change the working directory to that of the new project and setup eclipse project files
When you edit your pom file to add/remove dependencies you must resetup the eclipse project files through
mvn eclipse:clean eclipse:eclipse
and then do not forget to refresh ur project in eclipse :)
find more about maven with eclipse