How to build project with Maven
To build a Maven based project, open your console, change to your project folder where pom.xml file is placed, and issue this command :
mvn package
This will execute the Maven “package” phase.
Maven build lifecycle
Maven is run by phases, read this default Maven build lifecycle article for more detail. So, when the “package” phase is executed, all its above phases – “validate“, “compile” and “test“, including the current phase “package” will be executed orderly.
Maven is run by phases, read this default Maven build lifecycle article for more detail. So, when the “package” phase is executed, all its above phases – “validate“, “compile” and “test“, including the current phase “package” will be executed orderly.
“mvn package” example
When you run “mvn package” command, it will compile source code, run unit test and pack it depends on your “packaging” tag in pom.xml file. For example,
1. If “packaging” = jar, it will package your project into a “jar” file and put it into your target folder
File : pom.xml
<project ...> <modelVersion>4.0.0</modelVersion> <groupId>com.mkyong</groupId> <artifactId>Maven Example</artifactId> <packaging>jar</packaging> ...
2. If “packaging” = war, it will package your project into a “war” file and put it into your target folder.
File : pom.xml
<project ...> <modelVersion>4.0.0</modelVersion> <groupId>com.mkyong</groupId> <artifactId>Maven Example</artifactId> <packaging>war</packaging> ...

Hi mkyong, I have a question please, we have an ant build.xml, we want to migrate to maven, how to convert targets from build.xml to maven.
thanks, your help is appreciated.
how to genrate ear file from Maven?
when i run mvn package. i am getting the following error..
Are you using surefire to generate unit test report? What is your Maven version? Try use the latest.
You look have many dependencies not available errors, try comment them and run again.
i am runing the server in debuging mode i am getting this error:Could not initialize the ServletContextListener