目錄前言一、安裝配置jdk二、搭建Maven三、搭建Nexus四、批量上傳jar包五、maven setting文件配置,pom.xml配置前言Maven私服是:公司在自己的局域網(wǎng)內搭建的 maven遠程倉庫服務器,每個員工的電腦上安裝...
目錄
Maven私服是:公司在自己的局域網(wǎng)內搭建的 maven遠程倉庫服務器,每個員工的電腦上安裝 maven 軟件并且連接私服服務器,員工將自己開發(fā)的項目打成 jar 并發(fā)布到私服服務器,其它項目組就可以從私服服務器下載所依賴的組件(jar)
查詢系統(tǒng)是否已安裝jdk
rpm -qa|grep java
卸載已安裝的jdk
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64rpm -e --nodeps java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.2.el7.x86_64
驗證是否已經(jīng)卸載
rpm -qa|grep javajava -version
在usr下創(chuàng)建software目錄 , 將 jdk-linux-x64.tar.gz 上傳至該文件夾
mkdir /usr/software
解壓 jdk-linux-x64.tar.gz
tar -zxvf /usr/software/jdk-linux-x64.tar.gz
配置JDK環(huán)境變量,編輯 /etc/profile 文件
vi /etc/profile
先將光標(可以使用快捷鍵Shift+g)移到最后一行,然后輸入 i 進入編輯狀態(tài),粘貼如下內容,輸入Esc 進入命令模式 輸入:wq! 保存修改信息
export JAVA_HOME=/usr/software/jdk1.8.0_131export PATH=$JAVA_HOME/bin:$PATH
配置文件生效
source /etc/profile
測試 JDK 安裝
java -version
將 apache-maven-3.6.1-bin.tar.gz 上傳至 /usr/software
解壓 apache-maven-3.6.1-bin.tar.gz
tar -zxvf /usr/software/apache-maven-3.6.1-bin.tar.gz
配置Maven環(huán)境變量
vi /etc/profile
先將光標(可以使用快捷鍵Shift+g)移到最后一行,然后輸入 i 進入編輯狀態(tài),粘貼如下內容,輸入Esc 進入命令模式 輸入:wq! 保存修改信息
export JAVA_HOME=/usr/software/jdk1.8.0_131export MAVEN_HOME=/usr/software/apache-maven-3.6.1export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
配置文件生效
source /etc/profile
測試maven安裝
mvn -version
將 nexus-3.9.0-01-unix.tar.gz 上傳至 /usr/software
解壓 nexus-3.9.0-01-unix.tar.gz
tar -zxvf nexus-3.9.0-01-unix.tar.gz
定位到nexus-3.9.0-01/bin目錄下 , 修改nexus文件
# 先定位到usr/software目錄下cd /usr/software/nexus-3.9.0-01/bin/# 修改nexus文件vi nexus
修改文件的內容為:
run_as_user='root'run_as_root=false
修改nexus-3.9.0-01/etc/nexus-default.properties配置表中屬性
# Nexus服務監(jiān)聽的端口;application-port=8081# Nexus服務監(jiān)聽的主機;application-host=0.0.0.0# Nexus服務的上下文路徑nexus-context-path=/
開放8081端口號
firewall-cmd --add-port=8081/tcp --permanentfirewall-cmd --reload
啟動nexus
#使用cd命令 定義到/usr/software/nexus-3.20.1-01/bin目錄下cd /usr/software/nexus-3.20.1-01/bin# 啟動Nexus admin123# ./nexus run./nexus start
賬號:admin 密碼:admin123
1、先將本地maven/localrepository倉庫打一個完整的zip壓縮包,上傳至/opt
2、解壓localrepository.zip,進入/opt/localrepository目錄
3、創(chuàng)建腳本 touch mavenimport.sh,寫入以下內容;
#!/bin/bash# copy and run this script to the root of the repository directory containing files# this script attempts to exclude uploading itself explicitly so the script name is important# Get command line paramswhile getopts ":r:u:p:" opt; docase $opt in r) REPO_URL="$OPTARG" ;; u) USERNAME="$OPTARG" ;; p) PASSWORD="$OPTARG" ;;esacdonefind . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
4、輸入chmod a+x mavenimport.sh進行可執(zhí)行授權
chmod a+x mavenimport.sh
5、執(zhí)行導入命令 (注意:將地址換成自己的私服地址)
./mavenimport.sh -u admin -p admin123 -r http://ip:8081/repository/maven-releases/
D:\JAVA\maven-repositorytrue -->false -->com.your.plugins --> optional true http proxyuser proxypass proxy.host.net 80 local.net|some.host.com --> deploymentRepo repouser repopwd --> siteServer /path/to/private/key optional; leave empty if not used. -->nexus-releasesadminadmin123nexus-snapshotsadminadmin123 mirrorId repositoryId Human Readable Name for this Mirror. http://my.repository.com/repo/path -->nexus*http://192.168.31.148:8081/repository/maven-public/alimavenaliyun mavenhttp://maven.aliyun.com/nexus/content/groups/public/central | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. jdk-1.4 1.4 jdk14 Repository for JDK 1.4 builds http://www.myhost.com/maven/jdk14 default always --> | org.myco.myplugins | myplugin | | | ${tomcatPath} | | | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the inside the activation-property. | env-dev target-env dev /path/to/tomcat/instance -->nexusmy-repohttp://192.168.31.148:8081/repository/my-repo/truetruemy-repohttp://192.168.31.148:8081/repository/my-repo/truetruenexus alwaysActiveProfile anotherAlwaysActiveProfile -->
nexus-releasesNexus Release Repositoryhttp://192.168.31.148:8081/repository/maven-releases/nexus-snapshotsNexus Snapshot Repositoryhttp://192.168.31.148:8081/repository/maven-snapshots/
本文來源:https://blog.csdn.net/qq_41062545/article/details/121642715
來源:本文內容搜集或轉自各大網(wǎng)絡平臺,并已注明來源、出處,如果轉載侵犯您的版權或非授權發(fā)布,請聯(lián)系小編,我們會及時審核處理。
聲明:江蘇教育黃頁對文中觀點保持中立,對所包含內容的準確性、可靠性或者完整性不提供任何明示或暗示的保證,不對文章觀點負責,僅作分享之用,文章版權及插圖屬于原作者。
Copyright?2013-2024 JSedu114 All Rights Reserved. 江蘇教育信息綜合發(fā)布查詢平臺保留所有權利
蘇公網(wǎng)安備32010402000125
蘇ICP備14051488號-3技術支持:南京博盛藍睿網(wǎng)絡科技有限公司