MAVEN's summary

Source: Internet
Author: User
Tags repetition

Overview

MAVEN is a project management tool that helps us manage the construction, reporting, and documentation of our projects. In the process of learning maven, it is mainly to learn the management of project construction.


maven

For relatively small software development, MAVEN is not a lot of role, for the project comparison, need to develop a lot of modules, each module is independent, the role of MAVEN will become very obvious.

Multiple modules independent development, when the merger, there will be a variety of problems, the most obvious problem is to rely on the different version of the jar, MAVEN can help us solve this problem.


local warehouses, silos, and remote warehouses

Warehouse: The place where the jar is stored; a local warehouse: a warehouse that can be used only by this computer; a warehouse that is used by the local area network; a remote warehouse: a warehouse that can be used by a public network.

By default, after a project relies on the jar through MAVEN configuration, MAVEN will see if the jar exists in the local repository, and if it does not exist, it will go to the central repository to see if it exists (index complete), exists, downloads to the local repository, does not exist, and then an error occurs. This situation is generally not used, because, since a system uses MAVEN, then, there are many people develop a number of independent modules, at this time, we think, when our software to add a lot of dependence, and find a new person to work, the new person will be crazy, Because it takes a few days to download the jar from the central repository, this approach as usual practiced hand can, however, not be practical.

Through the solution of the problem, through the establishment of the Internal network server, the project relies on the jar for the purpose, at this time, the project depends on the process, the project through MAVEN configuration of the jar dependency, then Maven will first see if there is a jar in this warehouse, does not exist, Go to the configuration of the factory, to send the corresponding request to the non-government to see if their own warehouse exists, exist, directly to the line, does not exist the need to go to the central warehouse to see if the jar exists. When configuring a database, we need to be aware that we should configure the appropriate image for Maven to place the phenomenon of ultra vires requests, to ensure that the project can only get the jar from the database, not directly from the central warehouse to obtain the jar, of course, We can also make sure that the non-vires phenomenon does not occur by modifying MAVEN's central default factory, but it is best to configure mirroring.

Here to note that the central warehouse is not omnipotent, a lot of jars in the central warehouse is not found, so we should have a psychological preparation, when some jars can not be downloaded, it may be that the jar in the central warehouse does not exist (not our configuration problem), at this time, we practice is, Download the jar from the Web, and then publish it to the appropriate factory in the virtual network.


the scope and delivery of dependencies

Dependencies: The role of this dependency (jar) in the construction phase (compile, package, etc.)

Dependent delivery: Whether the dependency (Jar) can be passed

For the above concept, it is not clear, the following is specific about the scope and delivery of dependencies

In a MAVEN configuration, the scope tag, which has a different value for the scope control, represents the range of the dependency

Compile (Default): compilation scope is valid, and dependencies are stored when compiling and packaging

Test: The testing scope is valid, and this dependency is not used when compiling and packaging

Provided: Compile and test valid, generate war package will not join

Runtime: Valid, compile-time not dependent

Depending on the delivery, a packet depends on the B package, the B packet depends on the C package, these dependencies are managed through MAVEN, when the B package for the C package of the dependency range set test, then, a packet depends on the B package, the C package will be automatically added to a large dependency, if B for C package of the dependency range set to compile, A package will automatically depend on the C package (automatically add its reference)


maven integration and inheritance

In the development of the system, we are usually sub-module development, of course, the basis for the division of the module is also a variety of, some according to the function of the division, and some according to the division of professional areas, and so on, at this time, we divide by the function, the module division, we specifically develop a module, The module is divided according to the hierarchy, that is, the development of a module needs to create multiple projects, each project code a layer, at this time, when we use MAVEN to manage our project, there will be a corresponding problem: the duplication of operations, configuration information duplication, rely on version control difficulties.

MAVEN integration: Put multiple projects of a module through configuration, unified by a project POM control

Maven inherits the repeated configuration information from multiple projects in a module, all in the same project's Pom, and then the POM for several other projects, note that here we are to avoid a project to introduce unnecessary dependencies, We use the dependencymanagement tag for management, the child pom needs to display (version and range not written) in the introduction of the parent Pom dependency


Plugins

The plug-in is the core of Maven, MAVEN has 3 separate lifecycles, each of which is done via plug-ins, of course, these are MAVEN's own plug-ins, and we can add additional plugins to MAVEN and bind the plug-ins to their lifecycle execution time.

maven has a lot of plug-ins, specific we can be in Maven's official website (Apache) for the corresponding view (http://maven.apache.org/plugins/index.html), when we have the corresponding needs, We'll search the Internet.


Summary

MAVEN's specific operations, you can look at the online tutorial. From the above, Maven helped us to solve the problem of duplication in the construction, from our industry, in fact, we have been constantly looking to avoid duplication (design repetition, coding duplication, duplication of documents, build repetition, etc.), so, friends, to say goodbye to repeat refueling!

MAVEN's summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.