Maven What is it? ?


1、Maven First impression

I didn't touch... In some time before college maven This thing , Now I'm getting to know something about maven Project , We need to learn it systematically , So let's start with understanding its function !

2、 What is? maven?

  • Maven yes apache The next open source project , Is pure Java Developed and used only for management Java project ;

The above is a more official statement , What is the specific situation ?
In layman's terms , When we have more than one project, there will be more shelving packages referenced , And there will be a high repetition rate , You have to manually import all kinds of jar package , This is not friendly for practical operation , and maven This thing is to solve this problem ,maven This middleware design concept is equivalent to a warehouse , There are all kinds of shelf bags in the warehouse , For every need jar File to call jar file ;

3、 Use maven The benefits of

 Maven Use conventions in , Appointment java Which directory must source code be placed in , compiled java What directory must the code be placed in , There is a clear agreement in these catalogues , For the cooperative development of the project 、 Later maintenance is very convenient ;

 Maven Every action has a life cycle , For example, to perform mvn install You can do the compilation automatically , test , Packaging and other construction processes (maven It has its own set of operating commands , Simple and practical )

 I just need to define one pom.xml, Then put the source code in the default directory ,Maven Help us with other things , A lot of questions have been omitted for us , We don't need to pay too much attention to other issues besides development ;

Use Maven You can build projects with a high degree of Automation , Dependency management ( This is the use of Maven The biggest benefit ), Warehouse management .

 Cross platform

 Applied to large projects ,maven Sub module development , Improve development efficiency .

4、 Dependency management

Use it again maven It's mentioned in the benefits of , Let's talk about it in detail ;

Dependency means jar Interdependence between packages , For example, let's build a Struts2 When developing a framework for , Only have struts2-core-2.3.16.3.jar This jar You can't have a bag ,struts2-core-2.3.16.3.jar It depends on other things jar package , Dependency management refers to the use of Maven To manage the jar package ,Maven The way of management is “ Automatically download what the project needs jar package , Unified management jar Dependencies between packages ”.

5、 Project one click build

The project construction process includes 【 Clean up the project 】→【 Compile the project 】→【 Test project 】→【 Generate test reports 】→【 Packaging project 】→【 Deployment project 】 These steps , These six steps are the complete construction process of a project .
 Insert picture description here
I mentioned before maven The operation command of can be used in this process , Just use the command , For example, one click to start a project :Tomcat:run: You can run the project directly ;