Maven Study Notes (2): Maven Repository

Source: Internet
Author: User
Tags jboss

The Maven repository has few knowledge points and is easy to understand.

There are only two types of warehouses: Local warehouses and remote warehouses. The local repository is the repository on your machine and is configured in the setting. xml file:

1 <localRepository>E:/MavenStore</localRepository>

The local repository stores the dependencies downloaded from the remote repository and some self-installed builds when Maven is used to parse the project.

The remote repository is obviously a repository on the network, which is stored in a mysterious place (well, I don't know where it is ). When Maven parses a project, if there is no local dependency, it will automatically go to the central repository for download. If no dependency is found, an error will be reported.

The remote repository can be subdivided as follows:

-- Central Repository (the core of the maven world, which provides support for the vast majority of dependencies. Except for the copyright of oracle JDBC)

-- Private server (a private server is a central warehouse built locally or in a LAN. It is used to act as an external warehouse to obtain dependencies more quickly and conveniently. It also reduces the pressure on the central warehouse, only one central warehouse is available and cherished)

-- Public warehouse (used to check for missing items in the central warehouse, such as the public warehouse of JBoss)

 

So the order of obtaining dependencies is: Local warehouse-private server-central warehouse

 

As mentioned above, if the central warehouse does not have the necessary dependencies, We will retrieve them from the public database. How can we hook up with the public database? Undoubtedly, the most important thing we can play during project construction is the POM file. Execute the following Configuration:

1 <repositories> 2 <repository> 3 <ID> JBoss </ID> 4 <Name> JBoss repository </Name> 5 <URL> http://repository.jboss.com/maven2/ </URL> 6 <releases> 7 <! -- Indicates the dependency that supports downloading the released version --> 8 <enabled> true </enabled> 9 <! -- Set the update check frequency (never: Never always: check daily: interval: n every n minutes) --> 10 <updatepolicy> daily </updatepolicy> 11 <! -- Check the policy when a verification and verification error occurs (warm: Warning fail: an error is reported ignore: ignored) --> 12 <checksumpolicy> ignore </checksumpolicy> 13 </releases> 14 <snapshots> 15 <! -- Indicates that the snapshot version does not support dependency download --> 16 <enabled> false </enabled> 17 </snapshots> 18 <! -- Use the default layout (a simple understanding of the layout is to construct the physical path of the dependent storage according to the Rules) --> 19 <layout> default </layout> 20 </Repository> 21 </repositories>

In addition, remote Warehouses like JBoss can be accessed at will, but if they are on private servers within the LAN, not everyone can access them, in this case, the repository on the private server sets access interception. Only those with authentication information can access the repository. In this case, you need to configure the authentication information, which is configured in setting. in XML:

1 <servers> 2 <Server> 3 <! -- ID corresponds to the repository id --> 4 <ID> test-repository </ID> 5 <username> passport </username> 6 <password> 123456 </password> 7 </Server> 8 </servers>

Note that the server ID must be consistent with the ID of the warehouse to be accessed. This is a one-to-one association.

 

Let's take a look at the knowledge about Maven versions. At the beginning of my study, I was also very depressed. I just wanted to write the version number. What official version and snapshot version should I do. After learning, I found that this mechanism is very powerful and cute. The powerful snapshot version mechanism is that after a is set to snapshot, MAVEN will automatically add a timestamp after each update of A. When a is obtained by another project, maven will download the latest changes, so that all the projects dependent on a can be obtained at any time and the latest version is. After the development is complete, replace version A with the official version.

 

There is also an image in Maven, which is similar to a copy. For example, Amazon China is an image of Amazon in China, because the functions provided by both are basically the same, and it is much more convenient for tianchao to access Amazon China due to Professor Fang. Therefore, an image is such a thing.

 

The last is welfare. I may have the same questions as Maven beginners. How can I remember the coordinates of NIMA since so many years. Therefore, the repository search service was born.

-- Http://repository.sonatype.org/enter the name of the dependent project directly here, it will give you his coordinates, copy and paste it on OK.

-- The role of http://www.jarvana.com/jarvana is the same as above, functions are similar

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.