First, IntroductionNexus is a powerful MAVEN warehouse manager that greatly simplifies the maintenance of its internal warehouses and access to external warehouses. With Nexus you can have full control over every artifact in your maintained warehouse in just one place. Nexus is a set of "out-of-the-box" systems that do not require a database, which organizes data using the file system plus lucene. The Nexus uses ExtJS to develop the interface, using Restlet to provide complete rest APIs that are integrated with eclipse through M2eclipse. Nexus supports WebDAV with LDAP secure identity authentication. Nexus is: http://www.sonatype.org/nexus/go/to the official network Zip compressed package can be downloaded, extracted after the discovery of two folders, One is nexus-2.11.0-02, the other is sonatype-work; The first folder contains the files needed to run the nexus, which is required to run the Nexus, and the second folder directory contains the nexus generated configuration files, log files, warehouse files, etc. This directory file is backed up by default when the Nexus needs to be backed up.Second, set environment variablesLocate the Nexus Directorynexus-2.11.0-02In the Bin folder, add the directory path to the bin to the operating system's path variable.Third, startOpen the cmd command line, enter the Nexus command, you will see the following prompt: Start/stop/restart/install/uninstall, as long as the Nexus command to add one of these commands, as shown, first installed, and then started, After success, you can open your browser: http://localhost:8081/nexus/#welcomeand see the Welcome screen. Click the Log In button in the upper -right corner to log in, and the Nexus's default Administrator account password is admin/admin123.
Four, configure the NexusAfter logging in, you can see that there are repositories, click, Discover releases and snapshots warehouse, where releases represents the release warehouse of the module in the internal modules, Snapshots represents the warehouse that publishes the internal snapshot module. The 3rd party represents a warehouse that is dependent on third parties, three of which are hosted types of warehouses, where proxy type warehouses represent warehouses that look for data from a remote central repository.
We can see four types of warehouses: Group (Warehouse Group), hosted (host), Proxy (proxy), and virtual. Each of these types of format has MAVEN1 or MAVEN2, where we don't see Maven1. The policy for the warehouse indicates whether the warehouse is a release version or a snapshot (Snapshot) version of the warehouse.
In Figure 5, Nexus lists some of the default warehouses:
Public repositories: A warehouse group that aggregates all warehouse policies for release and provides services through a consistent address.
3rd party: A host-type warehouse with a policy of release, which is used to deploy components that cannot be obtained from a public warehouse.
Apache Snapshots: Policy is snapshots's agent repository, which is used to proxy the snapshot version artifacts of the Apache Maven repository.
Central: The warehouse agent for MAVEN's centralized repository, policy release, downloads and caches only the release builds in the central repository.
Central M1 Virtual type warehouse in SHADOW:MAVEN1 format.
Codehaus Snapshots: Agent Codehaus maven Warehouse Snapshot version of the Agent repository.
Release: the host type warehouse where the policy is release, which is used to deploy the release build artifacts within the organization.
Snapshots: The policy is snapshots's host type warehouse, which is used to deploy snapshot version artifacts within the organization.
Five, download indexClick on the left views/repositories-> below to appear repositories-> click on the right central-> click on the configuration below to download Remote Change the indexes value to True and click "Save", click on the" Administration "and" scheduled Tasks "link on the left, if" Update repositories Index "is not in the running state, you need to Right-click on the repositories line and tapUpdate Index"。 Then click Schedule tasks to see that the task is in running state. When the index download is complete, you can repositories theinterface, select the Browser Index tab to see the tree structure of the contents of the MAVEN central repository, as shown in. Enter the Spring keyword in the search box on the left and search for a bunch of spring-related results.Vi. Private Warehouse configuration Configure the remote repository in Settings.xml, the profile provided by Maven is an optional set of configurations that can be used to set or override the configuration defaults and add the following code to the Setting.xml file,
<profiles><profile><id>local_nexus</id><repositories><repository><id >local_nexus</id><name>local_nexus</name><url>http://localhost:8081/nexus/content/ Groups/public/</url><releases><enabled>true</enabled></releases><snapshots ><enabled>true</enabled></snapshots></repository></repositories>< Pluginrepositories><pluginrepository><id>local_nexus</id><name>local_nexus</name ><url>http://localhost:8081/nexus/content/groups/public/</url><releases><enabled> True</enabled></releases><snapshots><enabled>true</enabled></snapshots> </pluginRepository></pluginRepositories></profile></profiles><activeProfiles> <activeProfile>local_nexus</activeProfile></activeProfiles> |
The above configuration uses aIDto beLocal_nexusof the Profile, this Profilecontains the relevant warehouse configuration, and the configuration also uses theActiveprofileselement willNexusthis Profileactivated so that when the executionMavenAt the time of construction, the active ProfileThe warehouse configuration is applied to the project.
Through the above configuration, we will find the maven except from nexus Download artifacts are also downloaded from the central repository. Since this is the case, then we just want maven download requests are only through nexus maven The download request for the component of any warehouse will be transferred to the database. Modify the above configuration to the following configuration:
<profiles><profile><id>local_nexus</id><repositories><repository><id >local_nexus</id><name>local_nexus</name><url>http://localhost:8081/nexus/content/ Groups/public/</url><releases><enabled>true</enabled></releases><snapshots ><enabled>true</enabled></snapshots></repository><repository><id> Central</id><url>http://repo.maven.apache.org/maven2</url><releases><enabled> True</enabled></releases><snapshots><enabled>true</enabled></snapshots> </repository></repositories><pluginrepositories><pluginrepository><id>local_ nexus</id><name>local_nexus</name><url>http://localhost:8081/nexus/content/groups/ public/</url><releases><enabled>true</enabled></releases><snapshots>< Enabled>true</enabled></snapshots></pluginrepository><pluginrepository><id>central</id><url>http:// Repo.maven.apache.org/maven2</url><releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots></pluginrepository></ Pluginrepositories></profile></profiles><activeprofiles><activeprofile>local_nexus </activeProfile></activeProfiles> |
vii. deploying components to a We are a lot of people in the actual development process, then there are always some public modules or third-party components can not be downloaded from the Maven Central Library. We need to deploy these artifacts to the other developers for download. Users can configure the Maven Auto-Deploy widget to the Nexus 's hosting repository, or manually upload artifacts via the interface. using Maven to deploy artifacts to a Nexus Daily development of snapshot versions deployed to nexus snapshot release pom is configured as follows:
< distributionmanagement> <repository> <id>local_nexus_releases</id> <name>core Release Repository</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </ repository> <snapshotRepository> <id>local_nexus_snapshots</id> <name>core Snapshots Repository</name> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </ Snapshotrepository> </distributionmanagement> |
The Nexus's repository is read-only for anonymous users. To be able to deploy artifacts, we also need tosettings.xmlConfigure authentication information in:
<pre Name= "code" class= "plain" ><servers> <server> <id>local_nexus_releases</id> <username >admin</username> <password>admin123</password> </server> <server> <id>loca L_nexus_snapshots</id> <username>admin</username> <password>admin123</password> </server></servers> |
which, in the verification informationServiceof theIDshould be associated withPOMinRepositoryof theIDconsistent. InNexusInterface to manually deploy third-party components to the
In addition to our own components to be deployed on the Nexus , we may also deploy third-party artifacts (such assqlservice JDBC) to the Nexus . At this point, select a hosting repository (such as 3rdParty) on the Nexus interface and select the Artifact Upload tab below the page. Fill in the corresponding Maven coordinates. Then click on the "select Artifact (s) for Upload" button to select the widget to upload from this machine, then click the "Add Artifact" button to add it to the upload list. Finally, click the "Upload Artifact (s)" button at the bottom of the page to upload the widget to the warehouse.
Use Nexus to create a