1. Warehouse Layout
Any component has its own unique coordinates, which can be used to define its unique storage path in the warehouse, which is how Maven's warehouse layout is
The correspondence between paths and coordinates is: groupid/artifactid/version/artifactid-version-classifier.packaging. Where the GroupID is split with a period.
For example, Jersey-common-2.22.1.jar, whose POM is defined as follows (version inherits the parent Pom file)
<parent>
<groupId>org.glassfish.jersey</groupId>
<artifactId>project</artifactId>
<version>2.22.1</version>
</parent>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<packaging>jar</packaging>
<name>jersey-core-common</name>
So in Maven it's supposed to be, Org/glassfish/jersey/core/jersey-common/2.22.1/jersey-common-2.22.1.jar
2. Classification of warehouses
Maven warehouses are divided into two categories, local warehouses and remote warehouses, where remote warehouses include central warehouses, and other public libraries.
1) Local Warehouse
The default is under the C-drive user name. M2\repository, such as C:\Users\XXX\.m2\repository, can be modified in the Settings.xml file via the localrepository tag (commented out by default).
For scenarios that rely on local projects, when building a module, the install plugin installs the project's build output file to the local repository, so that other modules that rely on the component can be successfully relied upon.
Common MVN Clean Install
2) Remote Warehouse
Central Warehouse: Because the most original local warehouse is empty, Maven must know at least one of the available remote warehouses to find artifacts. The default remote repository is defined in $m2_home/lib/maven-model-builder-3.3.9.jar.
<repositories>
<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>
The file that contains this configuration is the Super Pom that all MAVEN projects inherit
Developers can also define the remote repository themselves, if you want to set the default remote warehouse to Jbosss, in the module's Pom file, the following definition:
<project>
....
<repositories>
<repository>
<id>jboss</id>
<name>jboss repository</name>
<url>http://repository.jboss.com/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
....
In this example, the releases and snapshots elements are more important, and they are used to control the download of Maven for the release and snapshot components.
In addition to Enabled, there are two properties for Updatepolicy and Checksumpolicy.
Updatepolicy indicates how often updates are checked from the remote warehouse, and by default, daily is checked once a day. Can have: Never never always check inverval:x every x minutes, x is any positive integer
Checksumpolicy represents a policy for checking inspection and documentation. When a component is deployed to the MAVEN repository, the corresponding checksum file is deployed. When I download a widget, maven verifies the checksum file, what if it fails? When the value is the default warn, only the warning message is output. Other values: Fail build failed ignore ignore error message
3. Certification of remote repositories
Add the Servers node in the settings.xml file.
<server>
Remote warehouse ID defined in the <id>deploymentrepo</id>//pom file
<username>repouser</username>
<password>repopwd</password>
</server>
4. Mirroring
If warehouse X can provide all the content stored in the warehouse Y, then you can assume that X is a mirror of Y. Because of the geographic location, sometimes mirroring can provide a faster service than a central warehouse.
For example, http://maven.net.cn/content/groups/public/is the central warehouse Http://repo1.maven.org/maven2 in China's mirror, of course, run faster than the West, so it can be used to replace the central warehouse
Set the following configuration in the Settings.xml file
<mirror>
<id>myMirror</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
All requests for download artifacts will be relocated to the web, which restricts the online download artifacts.
6. Deployment Artifacts
Use the Deploy command to deploy to a. Configuring the Distributionmanagement label under the project Pom file
<distributionManagement>
<repository>
<id>myrelease</id>
<name>my Release repo</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>mysnapshot</id>
<name>my Snapshot repo</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
If authentication is required, configure the server node in settings.xml with the user name and password, or the private key.
Maven notes (ii) warehouses