1. Local Repository)
The local repository is a local directory, which is used to store all dependencies of our project (the jar package of the plug-in has some other files). In short, when you build a Maven project, all the dependent files are stored in the local repository, which is available to all projects.
By default, the local repository is in the. m2 directory, and windows is the. m2 directory under your user name Directory.
1. Update the local repository Directory
Find the conf/setting. xml file in your MAVEN_HOME directory and update the localRepository node.
<Settings>
<! -- LocalRepository
| The path to the local repository maven will use to store artifacts.
|
| Default :~ /. M2/repository
<LocalRepository>/path/to/local/repo </localRepository>
-->
<LocalRepository> D:/maven/repo </localRepository>
2. Save it.
Finished. The new local repository is stored in D:/maven/repo.
Check this directory.
2. central repository)
When we build a Maven project, Maven will check our pom. xml file to define the project dependency. Maven will search for the dependency in the local repository. If the dependency is not found, download it from the maven Central Repository. The address is
Http://search.maven.org/#browse
It looks like this.
Note: Although this is a new central warehouse, sometimes it will be downloaded from the old warehouse http://repo1.maven.org/maven /.
3. Remote Respository)
In Maven, when your dependency in pom. xml is neither in the local database nor in the central database, an error is reported.
1. Example
Org. jvnet. localizer is only available in the java.net repository. But just understand)
The code is as follows: |
Copy code |
<Dependency> <GroupId> org. jvnet. localizer </groupId> <ArtifactId> localizer </artifactId> <Version> 1.8 </version> </Dependency> |
When we build, it will fail, and the error message not found is output #2. declare the java.net repository in order to tell Maven to obtain dependencies from the remote repository, we need to declare a remote repository in pom. write in xml
The code is as follows: |
Copy code |
<Repositories> <Repository> <Id> java.net </id> <Url> https://maven.java.net/content/repositories/public/ </url> </Repository> </Repositories> |
In this way, the order of Maven Search dependencies is: 1) if the local repository is not found, go to step 2; otherwise, Exit 2) if the central repository is not found, go to step 2, otherwise, log out. 3) go to the java.net remote warehouse to obtain the data. If the data is not found, an error is returned. Otherwise, exit. Add: JBoss also has a remote warehouse, which can be configured as follows:
The code is as follows: |
Copy code |
<Project...> <Repositories> <Repository> <Id> JBoss repository </id> <Url> http://repository.jboss.org/nexus/content/groups/public/ </url> </Repository> </Repositories> </Project> |