Create a local image from the maven Repository

Source: Internet
Author: User
1. Create a local image from the maven Repository

Http://blog.csdn.net/teamlet/archive/2007/04/22/1574642.aspx


2. Create a maven2 local code library server, which is often referred to as "private server"


The official Maven repository server is very slow. Do you still remember the last submarine cable Accident? The official server could not be accessed at all, and it was crazy during that time. In addition, the official server class library version is usually not the latest, and sometimes you have to do it yourself if you want to use the latest version. (The following describes how to manually create a local code server.

The Maven server is simple, just a common HTTP server, such as Apache.

Copy the folder of your local code library to the htpdocs/maven2 directory under the Apache installation directory. The Windows user is C:/Documents and Settings/Jeffrey /. m2/repository, which is/home/Jeffrey/in Linux /. m2/Repository (note. m2 is a hidden folder in Linux)

Start the Apache server and enter http: // localhost/maven2/repository in the browser. You can view the repository file directory.

Edit the project POM to specify the local code library Server

Add:


XML Code
  1. <Repositories>
  2. <Repository>
  3. <ID> mylibs <! -- </Span --> ID>
  4. <URL> http: // localhost/maven2/Repository <! -- </Span --> URL>
  5. <! -- </Span --> repository>
  6. <! -- </Span --> repositories>


Multiple repository records can be added. MVN searches in sequence. If none of them are found, MVN searches for the official server.

3. Add a new class library to the local code server.

Many class libraries on the maven official website cannot be found. You can only do it yourself.

Please first confirm that the official website does not exist and then do it yourself. After all, it is quite troublesome.

See the http://mvnrepository.com/,http://repo1.maven.org/maven2/ on two websites:

The preceding section describes how to organize the file directory of the maven code library. The same jar has an independent folder for each version to store. In addition to jar, the jar description file is also available. POM and their verification files. sh1

The. Pom file defines the name and version of the jar and other jar files that the jar depends on (that is why a jar is introduced but a lot of jar files are generated)

The simplest Pom is as follows:

Generate a verification file for jar and POM

You can use an ant task to do the following:
XML Code

  1. <! -- Generate checksum file for jar and pom -->
  2. <Target


Copy the generated sh1 files, Jar files, and pom files to the Apache code library according to the structure layout described above. Of course, you can copy them directly to the local code library.

XML Code

  1. XML version = "1.0" encoding = "UTF-8"?>
  2. <Project>
  3. <Modelversion> 4.0.0 <! -- </Span --> modelversion>
  4. <Groupid> net. Jeffrey <! -- </Span --> groupid>
  5. <Artifactid> XXX <! -- </Span --> artifactid>
  6. <Versions> 1.0 <! -- </Span --> version>
  7. <Dependencies>
  8. <! -- </Span --> dependencies>
  9. <! -- </Span --> Project>

From: http://hi.baidu.com/huang_max/blog/item/e204a2516ba9b82642a75bce.html

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.