Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Maven Central Warehouse on Centos

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to build a central Maven warehouse on Centos. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Environment

Install JAVA

To install java's jdk using yum here, you can use the instruction yum search java | grep jdk to see which jdk versions are available under yum. Version 1.8 is selected here, and the installation instruction is: sudo yum install java-1.8.0-openjd

After the installation, you also need to modify the environment variables. Here, we will add a java.sh file to / etc/profile.d to set the environment variables, as follows:

Cd / etc/profile.dsudo vim java.sh

Fill in the following contents:

# set java environmentJAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.7.0.75.x86_64JRE_HOME=$JAVA_HOME/jreCLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libPATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binexport JAVA_HOME JRE_HOME CLASS_PATH PATH

Then save and exit. (you need to understand the operation of vim here, which will not be discussed in detail in this article.)

Finally, when you start the environment variable with source / etc/profile, you can use java-version to see if the configuration is successful.

Install nexus

Use wget to get the installation package of nexus. I installed version 2.11.2 here, and the instructions are as follows:

The copy code is as follows:

Wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz

Then unzip it under the current directory and enter the folder:

Tar-zxvf nexus-2.11.2-03-bundle.tar.gzmv nexus-2.11.2-03 nexus # rename folder cd nexus

After unzipping, you can see that there are two folders, one is the nexus service, and the other is its private repository directory.

Then edit the nexus script, which is located in NEXUS_HOME/bin with the following instructions:

Vi bin/nexus

Change RUN_AS_USER to RUN_AS_USER=root

You also need to adjust your firewall configuration and open the appropriate ports, so I won't go into detail here.

Then start the nexus service with the following directive:

. / bin/nexus start

At this point, you can access the nexus service on the browser!

You can log in to the system from the Log In in the upper right corner. There are three default roles. We first use the role of admin to enter the system. The default password of admin is admin123.

Click users on the left to view the users of the current system. You can see a total of three users, admin,deployment and anonymous.

Admin: this user has full permissions for Nexus, and the default password is admin123.

Deployment: this user can access Nexus, browse the contents of the repository, search, and upload deployment artifacts, but cannot configure Nexus. The default password is deployment123.

Anonymous: this user corresponds to all anonymous users who are not logged in, who can browse the repository and search.

If we click on repositories, we can see that there are several default types. We will use repository of third-party type here, so we need to enable it to support compilation and upload.

There is a lot more that can be done through UI, which we will not repeat here. Here's how to upload a packaged jar to nexus locally via maven.

Maven packaging and deployment

First, we need to modify the local maven configuration to add the user name and password of the remote repository. First find the settings.xml file for the local maven. You can use mvn-version to find the address of maven:

You can see the address of Maven home here, then go to the settings.xml under this folder config and add server to it. Here we will use the third party warehouse.

Then add the following to the maven dependency of the project that needs to be packaged:

Org.apache.maven.plugins maven-compiler-plugin 1.8 1.8 org.apache.maven.plugins maven-jar-plugin 2.4 true lib/ maven-deploy-plugin deploy 3rd party REPOSITORY_URL

The REPOSITORY_URL here refers to the location of your warehouse, which can be found on the repository page shown earlier.

Instructions for maven packaging

Mvn clean package

At this point, you will see the packaged jar file in the. / target directory, and then deploy using the following directive:

Mvn deploy:deploy-file-DgroupId=com.xy.oracle-DartifactId=ojdbc14-Dversion=10.2.0.4.0-Dpackaging=jar-Dfile=./target/xxx.jar-Durl= http://IP:8081/nexus/content/repositories/thirdparty/-DrepositoryId=thirdparty

Then you can see the deployed jar package on the web side.

This is the end of the article on "how to build a central Maven warehouse on Centos". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report