How is the maven build different from eclipse build? - eclipse

I have integrated m2e plugin.When i change the java file .It invokes building workspace. Is this is eclipse build or maven build.
And what exactly the difference between Eclipse clean and mvn clean ?

The m2e plugin injects the Maven classpath into the Eclipse project plus it disables the default Eclipse resource copying so Maven can do it's magic (the Maven resource copy step can filter/transform resources).
The actual build for Java files uses the Eclipse compiler with the classpath supplied from m2e.
Clean: Unless you have configured something special, Eclipse clean will delete target/classes and target/test-classes while mvn clean will delete the whole target/ folder.
Also, Eclipse will build the project again right after clean. For Maven, you need to issue another command (mvn compile or mvn install).

Check your .project file.
Do you have something like org.eclipse.m2e.core.maven2Builder there? Then it's Maven build executed by Eclipse via m2e.
The exact difference between "Eclipse clean" and mvn clean...
mvn clean executes Maven clean phase, as it is configured (or inherited) in the pom.xml.
For Eclipse clean, see this question:
Function of Project > Clean in Eclipse

Related

add a specific jar from maven repository

In Eclipse i forgot how to add a specific jar from m2 repo in the case that we have a maven project without the m2e Plugin in Eclipse
From the command line, run mvn eclipse:eclipse to generate Eclipse metadata for your project, then restart Eclipse and, if needed, reimport your projects.
You'll need to repeat that for every dependency change. In the long run, you're probably better off using m2e.

Errorneous Message "No setter found for property" in eclipse kepler with Spring 3.2

Got an error in my Spring context file about an not existing setter for property, even it's existing. It's a Spring MVC project and it's compiling and working on my Tomcat.
IMHO it's a Eclipse problem (Eclipse Kepler) + or there seems to be a problem with Maven, which I am using with Eclipse.
It seems the issue with eclipse. You can check following things,
As it is a maven project the output folder is correct Java Build Path->Source->Default output folder is set to <ProjectName>/target/classes
If your able to build and run it from maven outside the eclipse then try to using same maven installation inside eclipse.
You can try run following maven command to refresh the build paths,
mvn clean install eclipse:clean eclipse:eclipse
There's something that i always do with Maven and Eclipse that works more often than not. If you can perform your mvn clean install outside of eclipse, then make sure the same maven is used inside inside Eclipse and then:
1/ project-->Properties-->Maven--> uncheck Resolve dependencies from Workspace projects --> Apply --> OK
2/ project-->Properties-->Maven--> check Resolve dependencies from Workspace projects --> Apply --> OK

How to add Maven dependencies in Eclipse libaries

Can any one explain how to add Maven dependency JAR i.e. build path libraries? To be very specific how to include JAR file mentioned in pom.xml to Java build path? Maven dependencies - unable to see jars over here.
Don't have a option to update Maven dependencies. Also executed the script mvn eclipse:eclipse, seen on StackOverflow.
Generally, you should not have any need to deal with such a task manually. Here is the correct procedure for importing of maven project to your Eclipse IDE:
Make sure you have m2eclipse plugin installed (Maven support for Eclipse). As far I remember it is included to Eclipse IDE for JEE developers by default.
Checkout your maven project to any directory
From this directory (root pom.xml is located in), run: mvn eclipse:eclipse
Go to Eclipse, File -> Import, select "Existing maven project"
Select directory where your root pom.xml is located, Eclipse should find all maven modules.
Optional: if eclipse will tell you that it can't recognize some maven plugins - ignore this, just continue.
If you follow this instruction, IDE will create all maven modules as eclipse projects and you will have an option to update maven dependencies and also willsee all of them rigth in IDE.

mvn eclipse:eclipse versus regular maven build

What is the difference between running a maven build on a maven project
mvn install
then importing the module in eclipse (Import > Existing Maven Projects) as a maven artifact versus running
mvn install eclipse:eclipse
and importing the maven project as a regular project (Import > Existing Projects into Workspace)?
The second option seems faster within eclipse (mvn install eclipse:eclipse) but I'm not sure why.
When you import an existing Maven project, it is done by m2e, the official Eclipse Maven plugin (when I say official I mean it is in the Eclipse incubation process). It offers more features and can be more convenient to use in my experience
When you do it by eclipse:eclipse, it is done by a Maven Eclipse mojo which creates a simple Java project. The problem is that you have to re-do this again every time you change your pom.xml. With m2e, this is usually done automatically.

Trying to understand how to work with Maven and Eclipse

I import a project into eclipse from svn and then go and run 'mvn install' from the command line and everything compiles fine. But I don't understand why the code is not compiled in Eclipse too.
From my previous experience I know that I need to go ahead in Eclipse and import "existing maven projects" to have Eclipse compile the code, I just don't understand why.
Thanks!
How have you imported the projects to Eclipse? By runnint mvn eclipse:eclipse to import them as 'Java project' or importing the maven projects directly with the m2eclipse plugin?
By default maven builds each project into a directory target in each project whereas Eclipse builds into eclipse-out. mvn install builds each maven project to create an archive (jar, war, ear etc) whereas Eclipse needs to build to be able to run the code in Eclipse.