Maven Introductory Series (ii)--How to set up a central warehouse

Source: Internet
Author: User
Tags stack trace

Original address: Http://www.codeweblog.com/maven Entry Series-two-method of setting up a central warehouse

Do you want to put the MAVEN repository in my documentation? Of course not, re-install the computer, meaning that all jars are to be re-downloaded and published.

The download address is the Central warehouse mvnrepository.com, of course, a lot of warehouses around the world.

resource's coordinate abbreviation GVA

Now, how do you modify MAVEN's local repository path?


The key is the Settings.xml (E:\IDE\apache-maven-3.3.1\conf\settings.xml) under the config of the Maven folder

  <!--localrepository
   | The path to the local repository maven would use to store artifacts.
   Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository> -
  

A note here can see that the local repository defaults to ${user.home}/.m2/repository.

(This article originates from: http://my.codeweblog.com/u/1156339/blog/396583)

If it's ~/.m2/repository under Linux,

Now if you want to change it, add the appropriate tag.

  <localRepository>E:\Java\maven\repos</localRepository>

Now we compile the Maven_2 project in the next previous blog (the jar that relies on the Maven_1 project, which was originally published to The Ontology repository):

E:\TESTSPACE\MAVEN_2&GT;MVN compile [INFO] scanning for projects ...
[INFO] [INFO]------------------------------------------------------------------------[INFO] Building maventest2 0.0.1- SNAPSHOT [INFO]------------------------------------------------------------------------downloading:https:// repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/
Maven-resources-plugin-2.6.pom downloaded:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- Resources-plugin/2.6/maven-resources-plugin-2.6.pom (8 KB at 3.4 kb/sec) downloading:https://repo.maven.apache.org/ Maven2/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom downloaded:https://repo.maven.apache.org/ Maven2/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom (9 KB at 14.3 kb/sec) downloading:https:// Repo.maven.apache.org/maven2/org/apache/maven/maven-parent/22/maven-parent-22.pom downloaded:https:// REPO.MAVEN.APACHE.ORG/MAVEN2/ORG/APACHE/MAVEN/MAVEN-PARENT/2 2/maven-parent-22.pom (at 23.9 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/apache/apache/11/
apache-11. Pom downloaded:https://repo.maven.apache.org/maven2/org/apache/apache/11/apache-11. Pom (at 14.3 kb/sec) Downloading:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- Resources-plugin/2.6/maven-resources-plugin-2.6.jar downloaded:https://repo.maven.apache.org/maven2/org/apache/ Maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar (KB at 16.7 kb/sec) downloading:https://
Repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom Downloaded:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/ Maven-compiler-plugin-3.1.pom (Ten KB at 6.6 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/apache/ Maven/plugins/maven-plugins/24/maven-plugins-24.pom downloaded:https://repo.maven.apache.org/maven2/org/apache/ Maven/plugins/maven-plugins/24/maven-plugins-24.pom (one KB at 5.4 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/ Apache/maven/maven-parent/23/maven-parent-23.pom downloaded:https://repo.maven.apache.org/maven2/org/apache/ MAVEN/MAVEN-PARENT/2 3/maven-parent-23.pom (up to 13.9 kb/sec) downloading:https://repo.maven.apache.org/maven2/ org/apache/apache/13/apache-13. Pom downloaded:https://repo.maven.apache.org/maven2/org/apache/apache/13/
Apache-13. Pom (KB at 12.7 kb/sec) Downloading:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- Compiler-plugin/3.1/maven-compiler-plugin-3.1.jar downloaded:https://repo.maven.apache.org/maven2/org/apache/ Maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar (KB at 14.6 kb/sec) downloading:https:// Repo.maven.apache.org/maven2/junit/junit/4.10/junit-4.10.po m downloaded:https://repo.maven.apache.org/maven2/ Junit/junit/4.10/junit-4.10.pom (3 KB at 2.1 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom downloaded:https://repo.maven.apache.org/maven2/ Org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom (481 B at 0.3 kb/sec) downloading:https://repo.maven.apache.org /MAVEN2/ORG/HAMCREST/HAMCREST-PARENT/1.1/hamcrest-parent-1.1.pom downloaded:https://repo.maven.apache.org/
MAVEN2/ORG/HAMCREST/HAMCREST-PARENT/1. 1/hamcrest-parent-1.1.pom (6 KB at 4.9 kb/sec) [WARNING] The Pom to Com.happybks.maven:maventest:jar:0.0.1-snapshot is mi Ssing, no dependency information available [INFO]------------------------------------------------------------------ ------[INFO] BUILD FAILURE [INFO]------------------------------------------------------------------------[INFO] Total time:21.691 s [info] finished at:2015-04-06t16:51:35+08:00 [INFO] Final memory:10m/108m [INFO]------------------ ------------------------------------------------------[ERROR] Failed to execute goal in project Maventest2:could not re Solve Dependen cies for proJect Com.happybks.maven:maventest2:jar:0.0.1-snapshot:could not fin D artifact com.happybks.maven:maventest:jar:0. 0.1-snapshot, [Help 1] [ERROR] [ERROR] to see the full stack trace of the errors, re-run Maven with THE-E swit ch. [
ERROR] Re-run Maven using the-x switch to enable full debug logging.
[ERROR] [ERROR] For more information on the errors and possible solutions, please rea d the following articles: [ERROR] [Help 1] http:/
 /cwiki.apache.org/confluence/display/maven/dependencyreso lutionexception e:\testspace\maven_2>

As a result, it's a bunch of downloads, because the local repository has changed and all the jars are going to be back down, like JUnit. However, because the new local repository does not have a jar for the Maven_1 project, compile an error.

At this point, we copy all the jars from the large default local repository in my original document to the new repos.


This is the time to compile


has been successful.

The second question: How do we set up our central warehouse on the line?

There are many jars under Lib (E:\IDE\apache-maven-3.3.1\lib) under the maven3.3.1 folder

There is a maven-model-builder-3.3.1.jar, open with decompression software, Org\apache\maven\model under a pom-4.0.0.xml file


Open the file

<?xml version= "1.0" encoding= "UTF-8"?> <!--Licensed to the Apache software Foundation (ASF) under one or more C  Ontributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License");  You are not a use of this file except in compliance with the License.  Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 unless required by applicable  or agreed to writing, software distributed under the License are distributed on a "as is" BASIS, without warranties OR  CONDITIONS of any KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License. -<!--START Snippet:superpom--<project> <modelVersion>4.0.0</modelVersion> <rep Ositories> <repository> <id>central</id> <name>central repository</name> <url>https://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </
      snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <name>central repository</name> <url>https://repo.maven.ap ache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>fals
      e</enabled> </snapshots> <releases> <updatePolicy>never</updatePolicy> </releases> </pluginRepository> </pluginRepositories> <build> <directory>$ {project.basedir}/target</directory> <outputdirectory>${project.build.directory}/classes</ Outputdirectory> <finalname>${project.artifactId}-${project.version}</finalName> <testoutputdirectory>${ Project.build.directory}/test-classes</testoutputdirectory> &LT;SOURCEDIRECTORY&GT;${PROJECT.BASEDIR}/SRC /main/java</sourcedirectory> <scriptsourcedirectory>${project.basedir}/src/main/scripts</ Scriptsourcedirectory> <testsourcedirectory>${project.basedir}/src/test/java</testsourcedirectory > <resources> <resource> <directory>${project.basedir}/src/main/resources</direc tory> </resource> </resources> <testResources> <testResource> <d 
    Irectory>${project.basedir}/src/test/resources</directory> </testResource> </testResources> <pluginManagement> <!--Note:these plugins is removed from the future versions of the Super POM--&G
      T <!--They is kept for the moment as they is very unlikely to CONFLICT with Lifecycle Mappings (MNG-4453)-<plugins> <plugin> <artifactid>mav en-antrun-plugin</artifactid> <version>1.3</version> </plugin> <plugi N> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version 
          > </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> </plugin> <plugin> <artifactid>m Aven-release-plugin</artifactid> <

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.