linux部署安裝maven私有庫
1、先安裝好jdk
2、下載sonatype Nexus
下載地址:http://pan.baidu.com/s/1dFJv5wl
3、在linux根目錄下創建文件夾
# mkdir nexus
4、將安裝包上傳至linux系統上
上傳至nexus文件夾內
# cd /nexus
5、解壓Nexus
# tar zxvf nexus-2.14.2-01-bundle.tar.gz
6、會解壓出2個文件夾
nexus-2.14.2-01(nexus服務,啓動也是這個)
sonatype-work(私有庫目錄)
7、配置一下Nexus端口和啓動參數
# cd /nexus/nexus-2.14.2-01/conf
# vi nexus.properties
[root@localhost conf]# vi nexus.properties # # Sonatype Nexus (TM) Open Source Version # Copyright (c) 2008-present Sonatype, Inc. # All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. # # This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, # which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. # # Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks # of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the # Eclipse Foundation. All other trademarks are the property of their respective owners. # # Sonatype Nexus # ============== # This is the most basic configuration of Nexus. # Jetty section application-port=8081 application-host=0.0.0.0 nexus-webapp=${bundleBasedir}/nexus nexus-webapp-context-path=/nexus # Nexus section nexus-work=${bundleBasedir}/../sonatype-work/nexus runtime=${bundleBasedir}/nexus/WEB-INF # orientdb buffer size in megabytes storage.diskCache.bufferSize=4096
application-port=8081(啓動後訪問的端口號,可以自行修改)
application-host=0.0.0.0(訪問限制,0.0.0.0表示任何地址都可以訪問)
我們保持默認不變,繼續。。。
8、編輯nexus腳本,配置啓動角色
# vi /nexus/nexus-2.14.2-01/bin/nexus
默認是下面這一條:
# RUN_AS_USER=
修改成:
RUN_AS_USER=root
9、linux防火牆打開8081端口:
# vi /etc/sysconfig/iptables
添加一條:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8081 -j ACCEPT
重啓防火牆:
# service iptables restart
10、啓動nexus
# /nexus/nexus-2.14.2-01/bin/nexus start
11、訪問Nexus
訪問地址:http://192.168.226.130:8081/nexus
Nexus剛啓動的時候,有默認的帳號和密碼,如果有需要可以自己去改
帳號:admin
密碼:admin123
12、配置maven連接Nexus私有庫
(maven安裝和配置這裏不詳細介紹了)
首先配置一下maven本地庫位置:
貼一下settings_dubbo.xml配置文件
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>D:/apache-maven-3.3.9/.m2/repository</localRepository> <interactiveMode>true</interactiveMode> <offline>false</offline> <pluginGroups> <pluginGroup>org.mortbay.jetty</pluginGroup> <pluginGroup>org.jenkins-ci.tools</pluginGroup> </pluginGroups> <!--配置權限,使用默認用戶--> <servers> <server> <id>nexus-releases</id> <username>deployment</username> <password>deployment123</password> </server> <server> <id>nexus-snapshots</id> <username>deployment</username> <password>deployment123</password> </server> </servers> <mirrors> </mirrors> <profiles> <profile> <id>edu</id> <activation> <activeByDefault>false</activeByDefault> <jdk>1.7</jdk> </activation> <repositories> <!-- 私有庫地址--> <repository> <id>nexus</id> <url>http://192.168.226.130:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <!--插件庫地址--> <pluginRepository> <id>nexus</id> <url>http://192.168.226.130:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!--激活profile--> <activeProfiles> <activeProfile>edu</activeProfile> </activeProfiles> </settings>
上面配置完成之後,在配置一下eclipse裏面的pom文件
<!-- 配置maven私有庫地址 --> <distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://192.168.226.130:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://192.168.226.130:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
13、配置完成之後,開始使用Nexus私有庫吧