In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to build maven private server, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Private service instructions
Maven warehouse is divided into local warehouse and remote warehouse, while remote warehouse is divided into maven central warehouse, other remote warehouse and private server (private server). Among them, the central warehouse is provided by the maven official, and the private service needs to be built by ourselves.
Maven private server is the maven remote warehouse in the company's local area network. Each employee's computer is equipped with maven software and connected to maven private server. Programmers can type their own projects into jar and publish them to private servers, and other project team members can download dependent jar from private servers. The private server also acts as a proxy server and automatically downloads from the maven central repository when there is no jar package on the private server.
Nexus is a maven warehouse manager (actually a software), nexus can act as maven private server, while nexus also provides powerful warehouse management, component search and other functions.
Set up maven private server
① download nexus
Https://help.sonatype.com/repomanager2/download/download-archives-repository-manager-oss
② install nexus
Decompress the downloaded package and enter the bin directory
Open the cmd window and go to the bin directory above, execute the nexus.bat install command to install the service (note that you need to run the cmd command as an administrator)
Search for cmd, right-click to run as administrator, cd to bin directory
③ starts nexus
After the previous command has completed the installation of nexus, you can start the nexus service in the following two ways:
Start nexus in the Windows system service
Win+r-> services.msc
Execute the nexus.bat start command on the command line to start nexus
④ accesses nexus
After starting the nexus service, access http://localhost:8081/nexus
Click the LogIn button in the upper right corner to log in. Log in to the system with the default username admin and password admin123
After logging in successfully, click the left menu Repositories to see the list of nexus built-in repositories (as shown below)
Nexus warehouse type
# warehouse type 1. Hosted (host) 1). Function: deploy self-developed (uploaded) jar to this type of warehouse 2). There are three I. Snapshots: ★ snapshot editions, the internal beta release repository, as long as the version of our project is followed by snapshot, the deployment will go to this warehouse II. Releases: ★ release version, as long as the tested code as long as our project version behind the release III. 3rd party: some third-party jar packages are not available in the central warehouse. We need to download them from the jar package website, and then manually upload them to this warehouse 2. Proxy (agent) 1). Function: used to represent the remote public warehouse, the jar package we want to use is downloaded from the remote warehouse and stored in this 2). Specifically, there are two I. Apache Snapshots: apache snapshot warehouse II. Central: maven central warehouse Chinese mainland is relatively slow Generally use private server instead of (Aliyun) 3. Virtual (virtual) central warehouse moved from the address of the former central warehouse central M1 shadow now the address of the central warehouse central 4. group (group)
As you can see from the previous warehouse list, nexus has built-in many repositories by default. These repositories can be divided into four types. Each type of warehouse is used to store specific jar packages, as described below:
① hosted, host repository, deploy your own jar to this type of warehouse
It is not a jar package for maven central warehouse.
0. Jar package version
Spring 5.2.9.RELEASE
1)。 Version number: large. Medium. Small
Small: modify a small bug to add functions
Medium: modify a more influential bug with relatively strong functions
Big: spring has a large version every three years
2)。 Version suffix
SNAPSHOT: snapshot (not fully tested)
RELEASE: release (fully tested)
Alpha (internal test) beta (public test) online (online)
1. Snapshots: ★ snapshot version, beta release repository for internal use
Projects that have not been fully tested within the company
2. Releases: ★ release, tested code
The fully tested projects within the company are more mature.
3. 3rd party: store the jar package of a third party (understand)
There is a class of jar packages that do not exist in maven's central warehouse.
To use this kind of jar package, you need to download it from the corresponding official website. After downloading it, we need to upload it to the private server and then use it.
(such as Oracle's jar)
② proxy, agent warehouse, used to represent remote public warehouses, such as maven central warehouse, users connect to private servers, private servers automatically go to the central warehouse to download jar packages or plug-ins
1. Apache Snapshots: the jar package downloaded by Apache's snapshot repository
2. Central: jar package downloaded by ★ Central Warehouse
The default is maven central warehouse, but we need to modify it to Aliyun later.
③ group, warehouse group, used to merge multiple hosted/proxy repositories. Usually we configure our own maven connection warehouse group
Warehouse group:
Releases: ★ release, tested code (upload our jar package: release)
Snapshots: ★ snapshot version, beta repository for internal use (upload our jar package: beta)
Central: jar package downloaded by ★ Central Warehouse (download jar package: changed to Aliyun Private Server)
④ virtual (virtual): jar or plug-ins that are compatible with Maven1 versions
Publish the project to maven private server (host warehouse)
Our current maven private server is a maven warehouse built on the company's local area network, which can be used by all development teams in the company. For example, if the technical R & D team has developed a basic component, it can be packed into a jar package and released to the private server, and other team members can download the jar package from the private server to the local warehouse and use it in the project.
The steps to publish the project to maven private server are as follows:
# Action: package and deploy the project to the host warehouse of nexus private server 1. Settings-nexus.xml file 1). Put the settings-nexus.xml in the data into the maven\ conf directory 2). Modify localRepository2 in the file. You need to modify the maven configuration file maven.user settings file-> settings-nexus.xml3 in idea. Modify the project pom file 1). Add a distributionManagement tag 2). Modify the version number suffix release release to releases warehouse snapshot release to snapshots warehouse 4. Maven instruction 1). Install installs jar package / war package to local warehouse 2). Deploy deploy jar package / war package to remote warehouse (private server)
Configure the settings.xml file for maven
Settings-nexus.xml
F:\ delvop\ apache-maven-3.6.1\ repository releases admin admin123 snapshots admin admin123 jdk-1.8 True 1.8 1.8 1.8 Dev nexus http://localhost:8081/nexus/content/groups/public/ True true Public Public Repositories http://localhost: 8081/nexus/content/groups/public/ dev
Note: be sure to configure it in the settings.xml file of maven introduced in the idea tool
two。 Configure the pom.xml file for the project
Which project you want to package and publish to the private server, add the relevant configuration to the pom.xml file of that project.
Equal to properties and dependencies.
Releases http://localhost:8081/nexus/content/repositories/releases/ snapshots http://localhost:8081/nexus/content/repositories/snapshots/
Execute the mvn deploy command
Download jar from private server to the local warehouse to modify the default central warehouse
The central warehouse of nexus is configured with the central warehouse of maven by default:
Https://repo1.maven.org/maven2/
Because the address is abroad, it is recommended to configure it as Aliyun:
Http://maven.aliyun.com/nexus/content/groups/public/
The above is all the contents of the article "how to build maven Private Server". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.