Maven Tutorial

Maven tutorials

Apache Maven, is an innovative software project management tool, provides new concept of a project object model (POM) file to manage project’s build, dependency and documentation. The most powerful feature is able to download the project dependency libraries automatically.

In this tutorials, it provides many step by step examples and explanations on using Apache Maven 2.x.

Happy learning Maven. :)

Maven Installation & Configuration

Installation guide on Windows and Ubuntu.

Maven Repository

Maven local, central and remote repository configuration and explanation, some terms you may need to understand before use Maven.

Maven based project and Eclipse IDE

Examples to create Java project and web application with Maven, and how to import it into Eclipse IDE.

Maven Basic Operations

Some basic operations, compile, build, unit test, install, generate site and deploy your Maven based project.

Maven FAQ

Some common Maven FAQs.

Maven Errors

Some common error messages in Maven.

Maven References

Tags :

About the Author

Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


  • Gaurav

    Amazingly practical knowledge presented in practical terms! :)

  • Gamola

    ? ????? MKYONG

  • Gamola

    MKYONG ????????? ????? ????? ???? ???????!

  • Malathi


    Thanks for this tutorials .It is very simple to learn and achieves everything which we need

  • Amol

    Thanks.Very helpful

  • Laura

    Your tutorials are so simple and yet covers all that matters…
    Thank you very much!

  • Benson

    Hey,mkyong.May I ask you a question?
    I created a Maven Project using maven-archetype-quikstart plugin in Eclipse 4.2.2. When I right click the pom.xml and run mvn test command,what I saw in console is the following:

    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] Building Maven Hello World Project 1.0-SNAPSHOT
    [INFO] ————————————————————————
    constituent[0]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/aether-api-1.13.1.jar
    constituent[1]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/aether-connector-wagon-1.13.1.jar
    constituent[2]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/aether-impl-1.13.1.jar
    constituent[3]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/aether-spi-1.13.1.jar
    constituent[4]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/aether-util-1.13.1.jar
    constituent[5]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/commons-cli-1.2.jar
    constituent[6]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-aether-provider-3.0.5.jar
    constituent[7]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-artifact-3.0.5.jar
    constituent[8]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-compat-3.0.5.jar
    constituent[9]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-core-3.0.5.jar
    constituent[10]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-embedder-3.0.5.jar
    constituent[11]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-model-3.0.5.jar
    constituent[12]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-model-builder-3.0.5.jar
    constituent[13]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-plugin-api-3.0.5.jar
    constituent[14]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-repository-metadata-3.0.5.jar
    constituent[15]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-settings-3.0.5.jar
    constituent[16]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/maven-settings-builder-3.0.5.jar
    constituent[17]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/plexus-cipher-1.7.jar
    constituent[18]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/plexus-component-annotations-1.5.5.jar
    constituent[19]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/plexus-interpolation-1.14.jar
    constituent[20]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/plexus-sec-dispatcher-1.3.jar
    constituent[21]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/plexus-utils-2.0.6.jar
    constituent[22]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/sisu-guava-0.9.9.jar
    constituent[23]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/sisu-guice-3.1.0-no_aop.jar
    constituent[24]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/sisu-inject-bean-2.3.0.jar
    constituent[25]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/sisu-inject-plexus-2.3.0.jar
    constituent[26]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/wagon-file-2.4.jar
    constituent[27]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/wagon-http-2.4-shaded.jar
    constituent[28]: file:/E:/ASF/apache-maven-3.0.5-bin/apache-maven-3.0.5/lib/wagon-provider-api-2.4.jar
    Exception in thread “main” java.lang.UnsatisfiedLinkError:
    at Method)
    at Source)
    at Source)
    at Source)
    at Source)
    at org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager.readRepos(
    at org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager.find(
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.readArtifactDescriptor(
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(
    at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecution(
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecutions(
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(
    at org.apache.maven.lifecycle.internal.BuilderCommon.resolveBuildPlan(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
    at org.apache.maven.DefaultMaven.doExecute(
    at org.apache.maven.DefaultMaven.execute(
    at org.apache.maven.cli.MavenCli.execute(
    at org.apache.maven.cli.MavenCli.doMain(
    at org.apache.maven.cli.MavenCli.main(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(

    BTW,it works when I run it in prompt.
    Any helps would be appreciated!

  • satish

    Hai mkyong, this satish developing web application using spring3 mvc and Hibernate with maven and jboss,I’m configuring all the dependecies in pom.xml but my problem is how to configure jboss4.2.3 in pom.xml using maven 2.x to deploy the web application war file in jboss server deploy folder automatically.? Can you guide me Regarding this post????????

  • Meenu Khurana

    whenver I try to use any MVN command i get the following error.

    C:\>mvn eclipse:eclipse -Dwtpversion=1.5
    [INFO] Scanning for projects…
    [INFO] Searching repository for plugin with prefix: ‘eclipse’.
    [INFO] org.apache.maven.plugins: checking for updates from central
    [WARNING] repository metadata for: ‘org.apache.maven.plugins’ could not be retri
    eved from repository: central due to an error: Error transferring file: Connecti
    on refused: connect
    [INFO] Repository ‘central’ will be blacklisted
    [INFO] ————————————————————————
    [INFO] ————————————————————————
    [INFO] The plugin ‘org.apache.maven.plugins:maven-eclipse-plugin’ does not exist
    or no valid version could be found
    [INFO] ————————————————————————
    [INFO] For more information, run Maven with the -e switch
    [INFO] ————————————————————————
    [INFO] Total time: 1 second
    [INFO] Finished at: Thu May 02 11:47:01 IST 2013
    [INFO] Final Memory: 1M/4M
    [INFO] ————————————————————————

    How to resolve this error?

    • Praveen Kumar

      Everything in maven done through plugins.And “org.apache.maven.plugins:maven-eclipse-plugin” is not available in your repository. To solve this issue, try to point remote reopsitory( configure it in settings.xml in maven installed dir),so that maven can download required plugins from from remote repositories.

  • Anonymous

    Can you message me with some hints on how you made this web site look this cool, I??d be thankful.

  • yacoubi

    Please can i find here maven+ hibernate/facetsJPA/spring3+jsf

  • Matt

    I actually Feel posting, _Maven Tutorial_ was good!
    I actuallycan’t see eye to eye together with u more! Finally looks like Istumbled upon a blog truly worth browsing. I appreciate it, Cynthia

  • iraj

    I want to create a table as below:

    | ID | BlockerID | BlockedID |
    | 1 | 5 | 6 |
    | 2 | 5 | 7 |
    | 3 | 5 | 8 |
    | 4 | 5 | 10 |
    | 5 | 9 | 5 |

    So 5 has blocked 6, 7, 8, 10 and 9 has blocked 5.

    Is possible to do thins like this:

    public class Blockee

    @GeneratedValue(strategy= GenerationType.AUTO)
    private int blockeeid;

    @OneToMany(cascade= {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(name=”BLOCKEE”, joinColumns= {@JoinColumn(name=”BLOCKER_ID”)},
    private User userid;

    @OneToMany(cascade= {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(name=”BLOCKEE”, joinColumns={@JoinColumn(name=”BLOCKED_ID”)},
    private Collection userlistId;

    //getters and setters


    Here is my User class:

    @Table(name = “USER”)
    public class User

    @Column(name = “USER_ID”)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int userid;

    @Column(name = “FIRSTNAME”, nullable = true, unique = false)
    private String firstname;

    @Column(name = “LASTAME”, nullable = true, unique = false)
    private String lastname;
    //getters and setters


    Or who can I do it with JPA?


  • Naresh

    mvn site:stage related configuration and examples, as I’m running automation test cases and the cases are executing multiple time(i.e two times).

  • mamu

    good work it is really helpfull us………..

  • dli7mar

    Can I put maven pom jars into a folder in Eclipse? My pom jars are in the root of the project, it’s not good for the layout, especially when I have many jars.


  • Alex.Chen

    thanks.learn a lot of things

  • Luiz Valença

    Thanks a lot! Your tutorials helped me today!

  • Rakesh Kumar Mohanty

    This Side Save my Job Some times because it really helps in understanding the concept and then the person in good touch to implement the concepts.Thanks

    • Surya Namala

      Its really helpful for beginers

  • Sheeraz

    Hi mate,

    Just want to know that how can I deploy artefacts using -DaltResposiory=releaseRespotirt::::, the problem is that I do not know what to provide for ‘layout’ value? I have around 16 projects and I ant to deploy all one by one and can not use as I want to control my deployment via settings.xml. I have defined two repository ‘releaseRepository’ and ‘snapshotRepository’ and want to switch at build time via parameters passed. Your comments will be appreciated.



    • Sheeraz

      This is the correction for above comment;

      I can not use



  • snowdream

    The http link for the article “Generate javadoc jar for Maven based project” is wrong,you may be change it to

  • Bhushan

    god of tutorials .. Detailed and simple steps explanation is awesome.. Keep it Up

  • Rakesh Sharma

    Very nice piece of information at one location…thnx

  • Nitin

    You are the God of tutorials.. Helped me a lot in understanding maven..Thanks!!!

  • Prasad Chande

    Thanks for your guidance. really Helpfull.

  • jainy

    Hi mkyong,
    I did setting for Maven following your previous tutorials,but when i run this goal “mvn archetype:generate” in command window, build failed showing
    [ERROR] No plugin found for prefix ‘archetype’ in the current project and in the
    plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the….

    Have checked proxy settings in “Internet Options” but there was nothing,have stucked here .
    Please tell me some solution so that I can go forward.


  • http://- Ram

    Hi Mkyong,
    Superb work !! These are masterpieces !! Thanks for writing all these articles and these will certainly help the development community and we have very less time digging the specifications published by these Opensource development teams !! Keep doing the work! I appreciate if you can publish your ideas on designing the webservices concepts (i mean the desing issues like performance, scalability, availability and standard approaches for services design etc)…

    And finally, coming to build, I liked these articles but wanted to ask you one questions…. Suppose If I have some JSPs, Java files, XLS files etc in my web application, and I want to rebuild the specific areas of changes rather than…. all the content.. i.e, If I change the JSPs then build that part and deploy and If I change XSL file build those files got modified and deploy rather than build everything .. How can i do that?


  • Loknath Reddy

    If it is a java example I am looking for…then i look for

  • optimization

    Valuable information. Lucky me I discovered your site by accident, and I’m shocked why this twist of fate did not happened in advance! I bookmarked it.

  • zhanglongyang

    Thanks a lot! Your tutorials are great.

  • kiran


    I want to read the names of services for which i have given build?Please help me


  • killer

    Thanks nice tutorial..

  • Michael

    Thank you for your effort to put this together in a easy to read style.

  • Albert

    Great style, right to the point. Will save it as a good reference for Maven. Thank you heaps for your efforts.

  • Maven Video Tutorial

    Thank you for these tutorials .
    Maven is a powerful project management tool.

  • salman

    Hello Mr Young,

    I am doing as instructed.On the command line i see maven downloading dependencies.But in the end i am not able to find any jar files in local repository.Please suggest a resolution for this.

    Many Thanks

    • mkyong

      When you use Maven to build your project, it will download the dependencies that declared in your project pom.xml

      For example, if you are using Eclipse, uses “mvn eclipse:eclipse

    • myths


      thanks mkyong for helping us out with these tutorial.

      i shall answer to this question with your permission ,actually all the dependencies are combined together and stored in common jar format.

      when you install the dependencies by mvn install it looks in some of the maven repositories and installs the respective dependencies.

      now if your requirement is to see all the dependencies in common folder use this command
      “mvn dependency:copy-dependencies”
      this will store all the dependencies in your target/dependency folder.

  • irobertyu

    I think the main thing to use dependency management of maven is like that,
    1, install maven plugin
    2, set local repository in .m2/setting.xml and activate it.
    3, click ‘mvn test’ to download dependency library automatically.

  • MarwaGamal

    thanks a lot for your effort .

    i have a semi problem , my archetype local catalog is empty , so when i try

      mvn archetype:generate

    it shows only the remote repository templates

    when i force using local repository

      mvn archetype:generate -DarchetypeCatalog=local

    no thing shows up , there isn’t any template there

    so what could i do ??
    thanx in advance

  • Dhayanidhi


    I am new to Maven. I am using Maven3.0.
    Your tutorials are good.
    Could you please suggest what is the option number I need to choose to generate folder structure for java project in maven 3.0?

    Thanks And Regards

  • addicted_guy

    mkyong hattsoff to you man, i appreciate your effort to opensource your thoughts and tutorials, immense thanks to you :)

    take care

  • Jim


    Just a question about maven which has cropped up in the mkyong hibernate tutorial:

    I know tutorials require effort to keep up-to-date so this is not a critical comment.

    When I get a message such as:

    Unable to find resource '' in repository central (

    What am I supposed to do about it? It doesn’t say whether or not I’m supposed to do anyhting to fix it or that it is okay to proceed as is.

    • mkyong

      Mind to share me your Maven’s hibernate coordinate in pom.xml?