Maven course

Maven Translate into " Experts "、" Expert ", yes Apache The next pure Java Open source projects developed . Based on project object model ( abbreviation :POM) concept ,Maven Using a central piece of information can manage the construction of a project 、 Steps such as reports and documents .

Maven Is a project management tool , Yes Java Build the project 、 Dependency management .

Maven It can also be used to build and manage various projects , For example C#,Ruby,Scala And projects written in other languages .Maven Was Jakarta Subprojects of the project , Now for Apache The software foundation hosts an independent Apache project .

Before reading this tutorial , What you need to know

This tutorial is mainly for beginners , Help them learn Maven The basic functions of the tool . After completing this tutorial, your Apache Maven Our professional knowledge will reach a medium level , Then you can learn more advanced knowledge .

Read this tutorial , You need to have the following Foundation :Java Basics .

Maven function

Maven Can help developers do the following :

  • structure
  • Document generation
  • report
  • Rely on
  • SCMs
  • release
  • Distribute
  • Mailing list

Contract configuration

Maven Advocate a common standard directory structure ,Maven The principle of using conventions over configuration , We should follow this directory structure as much as possible . As shown below :

catalogue Purpose
${basedir} deposit pom.xml And all subdirectories
${basedir}/src/main/java Of the project java source code
${basedir}/src/main/resources Project resources , for instance property file ,springmvc.xml
${basedir}/src/test/java Test class of the project , for instance Junit code
${basedir}/src/test/resources Resources for testing
${basedir}/src/main/webapp/WEB-INF web Application file directory ,web Project information , Such as storing 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 Maven Only test classes that conform to this naming rule will be automatically run
~/.m2/repository Maven Default local warehouse directory location

Maven characteristic

  • Project settings follow uniform rules .

  • Share in any project .

  • Dependency management includes automatic updates .

  • A huge and growing library .

  • Scalable , Can easily write Java Or script language plug-ins .

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

  • Model based construction − Maven The ability to build any number of projects into predefined output types , as JAR,WAR Or distribution based on project metadata , You don't need to execute any scripts in most cases .

  • Consistency of project information site − Use the same metadata as the build process ,Maven Be able to generate a website or PDF, Include any documents you want to add , And added to the standard report on project development status .

  • Release management and release separate output − Maven No additional configuration will be required , It can be connected with the source code management system ( as Subversion Or Git) integrate , And you can manage the release of the project based on a label . It can also publish it to a distribution location for use by other projects .Maven Ability to publish separate output , as JAR, Archive containing other dependencies and documents , Or publish as source code .

  • Backward compatibility − You can easily from the old version Maven Migrate multiple modules of to Maven 3 in .

  • When a child project uses a parent project dependency , Normally, a child project should inherit the parent project dependency , No version number is required ,

  • Parallel build − The speed of compilation can be generally improved 20 - 50 %.

  • Better error reporting − Maven Improved error reporting , It provides you with Maven wiki Links to pages , You can click the link to see the full description of the error .