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>
...
I am getting this error-
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories
Please help me resolve this issue.
Hi. My project team is using maven build. We have a package name as **/**/**/RCS under which all the classes are getting generated. But the jar does not contain these classes for some reason. Is there a way to include these classes into the RCS.jar?
There is no problem with other packages having a similar format.
Please suggest where the issue can be.
Thanks in advance!!!
Normally I do not learn article on blogs, however I wish to say that
this write-up very forced me to check out and do it! Your
writing taste has been amazed me. Thank you, quite nice post.
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