WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Maven tutorial


Maven translates as "expert" and "professional", and is an open source Java-developed project under Apache. Based on the project object model (abbreviation: POM) concept, Maven uses a central piece of information to manage the steps of a project's construction, reporting, and documentation.

Maven is a project management tool that can build and dependency manage Java projects.

Maven can also be used to build and manage various projects, such as projects written in C #, Ruby, Scala, and other languages. Maven was a sub-project of the Jakarta project and is now an independent Apache project hosted by the Apache Software Foundation.


What you need to know before reading this tutorial

This tutorial is intended for beginners to help them learn the basic features of the Maven tool. After completing this tutorial, your Apache Maven expertise will reach intermediate level, and then you can learn more advanced knowledge.


Maven features

Maven can help developers do the following:

  • Building
  • Document generation
  • Report
  • Dependencies
  • SCMs
  • Post
  • Distribution
  • Mailing list

Conventional configuration

Maven advocates a common standard directory structure. Maven uses the principle of convention over configuration. Everyone should follow this directory structure as much as possible. It looks like this:

Directory Purpose
$ {basedir} Store pom.xml and all subdirectories
$ {basedir}/src/main/java Java source code for the project
$ {basedir}/src/main/resources Project resources, such as property files, springmvc.xml
$ {basedir}/src/test/java Test class for the project, such as Junit code
$ {basedir}/src/test/resources Test resources
$ {basedir}/src/main/webapp/WEB-INF web application file directory, web project information, such as web.xml, local pictures, jsp view page
$ {basedir}/target Package output directory
$ {basedir}/target/classes Compile output directory
$ {basedir}/target/test-classes Test compilation output directory
Test.java Maven will only automatically run test classes that meet the naming rules
~/.m2/repository Maven's default local repository directory location

Maven Features

  • Project settings follow uniform rules.

  • Share in any project.

  • Dependency management includes automatic updates.

  • A huge and growing library.

  • Extensible to easily write plug-ins for Java or scripting languages.

  • Instant access to new features with little or no additional configuration.

  • Model-based build − Maven can build any number of projects into predefined output types, such as JAR, WAR, or project metadata-based distribution, without the need for In most cases execute any script.

  • Consistent site for project information − Using the same metadata as the build process, Maven is able to generate a website or PDF, including any documents you want to add, and add to the project Standard report of development status.

  • Release management and release separate output − Maven will integrate with a source code management system (such as Subversion or Git) without additional configuration and can be based on a tag Manage project releases. It can also publish it to distribution locations for use by other projects. Maven can publish individual outputs such as JARs, archives containing other dependencies and documentation, or publish as source code.

  • Backward compatibility − You can easily port multiple modules from an older version of Maven to Maven 3.

  • When a child project uses a parent project dependency, the child project should inherit the parent project dependency under normal circumstances, without using a version number,

  • Parallel builds − Compilation speed can generally be increased by 20-50%.

  • Better error reporting − Maven has improved error reporting, which gives you a link to the Maven wiki page, and you can click the link to see a full description of the error.