1. Install and use Nexus 3
1: Download address: https://help.sonatype.com/repomanager3/product-information/download
After Windows decompression:
2: Enter the /nexus-3.61.0-02/bin directory, start the cmd command to open the command window, and enter nexus /run and wait for startup h4>
3: The default request address after startup is completed: http://localhost:8081/
Default account password: admin / admin123
Interface display:
4: Installation on linux
First download the Linux compressed package and upload it to the server. The configuration file locations are the same. In Linux environment, please note that you need to open the port corresponding to nexus.
start command (in the form of background process)
./nexus startVisit the Nexus web homepage with your browser and enter the Linux server ip:8081
Note: Do not use root user to start nexus
2. Set Nexus 3 as a system service to start in Windows
1: Still in the /nexus-3.61.0-02/bin directory, start the cmd command to open the command window, and enter nexus.exe /install nexus3 (The command prompt window needs to be opened in administrator mode, otherwise an error will be reported, which will occur in Windows 7)
2: After the installation is completed, go to Control Panel –> Management Tools –> Services to view the nexus3 service (the default is not started, the corresponding service needs to be started)
Note: The service startup process takes a certain amount of time, and you need to wait for a certain amount of time to open http://localhost:8081/ in the browser.
3. Configure nexus and become familiar with the meaning of the corresponding folders
1: File structure
nexus- 3.5.2-01 Installation directory
bin Contains nexus startup scripts and related configurations
etc Jetty, karaf and other configuration files
jre jre environment
lib java package library
public About the resources needed to run nexus applications locally
systemApply all plug-ins and components
LICENSE.txt and NOTICE.txt Copyright Statement and Legal Details
sonatype- work\\
exus3 Data document
blobs/ The default path for creating blobs. If you specify an absolute path, it will not be here.
cache/ Information about the currently cached karaf package
db/ OrientDB database data, a database used to store nexus metadata
elasticsearch / Current configured Elasticsearch status
etc/ It is probably related to the runtime configuration status and customization of the resource library.
health-check/ Look at the directory, the directory where health check related reports are stored.
keystores/ Automatically generated ID primary key about the resource library
log/ The log file generated by the running instance also has a compressed package of the log file. It seems that the log file is generated every day. You can delete the old log file regularly.
tmp/ Directory for storing temporary files
2: JVM parameters of nexus application
3: The port number for nexus startup can be configured in nexus-default.properties
application-port port number
application-host request address
nexus-context-path / can be changed to /lkx/ then the request address is http://localhost:8081/lkx/
4. Build a maven private warehouse (key points)
1: Customized file storage directory (convenient for unified management)
2: First introduce the corresponding structural directory (mainly focusing on maven’s resource library)
These are my own understandings
The proxy is a resource library configured with the Maven remote warehouse address on the external network. If it cannot be found locally, the remote warehouse will be found through the address in the proxy and the required jars will be downloaded from the remote warehouse.
group can configure multiple proxy and hosted in this group resource library
Hosted is a local resource library. Various jars cannot be downloaded from the remote warehouse. You can only find them online. Download the jars you find, put them in the hosted resource library, and hand them over to Nexus for unified management.
3: proxy Proxy resource library (take my Alibaba Cloud proxy as an example)
4: hosted repository
There are three ways to host, Releases, SNAPSHOT, and Mixed
Releases: Generally, it is a Jar package that has been released
Snapshot: Unreleased version
Mixed: Mixed
Select maven2 (hosted) when creating
Change the deployment update policy to Allow redeployment
5: group Group Resource Library
Select maven2 (group) when creating
5. Package the maven project into the nexus private warehouse
1: Configure the setting.xml file
1. Configure in servers
yizhuo-maven
admin 123456
2. Configure in mirrors
yizhuo-maven
central
Nexus aliyun
https://maven.aliyun.com/nexus/content/groups/public
yizhuo-maven
*
http://localhost:8081/repository/yizhuo/
2: Reference the corresponding setting.xml file in the corresponding Maven project, and configure the pom to push the jar to the private maven warehouse configuration
[1]: Configuration settings
[2]: Configure the pom to push the jar to the private maven repository of nexus
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.yizhuo</groupId> <artifactId>yz-core</artifactId> <version>1.0.13</version><!--Corresponding jar package version number--> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> <distributionManagement> <repository> <id>yizhuo-maven</id> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>yizhuo-maven</id> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> <profiles> <profile> <id>disable-javadoc-doclint</id> <activation> <jdk>[1.8,)</jdk> </activation> <properties> <javadoc.opts>-Xdoclint:none</javadoc.opts> </properties> </profile> </profiles> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.10.4</version> <executions> <execution> <id>attach-javadocs</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <additionalparam>-Xdoclint:none</additionalparam> </configuration> </execution> </executions> </plugin> <!--Generate source code jar package (corresponding comments can be packaged together) --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
[3]: Use idea tools to package and push
[4]: View push results in nexus
[5]: Use the jar package in the maven repository in nexus in other projects
The project setting file first configures the modified setting file.
Reconfigure and reference maven in the dependences of the pom.xml file
<dependency> <groupId>org.yizhuo</groupId> <artifactId>yz-core</artifactId> <version>1.0.12</version> </dependency>
result: