歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

Linux下安裝maven和nexus,linuxmavennexus

Linux下安裝maven和nexus,linuxmavennexus


熱度5 評論 184 www.BkJia.Com  網友分享於:  2017-03-02 04:03:45     浏覽數33267次

Linux下安裝maven和nexus,linuxmavennexus


Linux下安裝maven
1.首先到Maven官網下載安裝文件,目前最新版本為3.0.3,下載文件為apache-maven-3.0.3-bin.tar.gz,下載可以使用wget命令;

2.進入下載文件夾,找到下載的文件,運行如下命令解壓
tar -xvf apache-maven-2.2.1-bin.tar.gz

解壓後的文件夾名為apache-maven-3.0.3

3.使用mv命令將apache-maven-3.0.3文件夾拷貝到自己指定的文件夾,比如/usr/local/下
mv -rf apache-maven-3.0.3 /usr/local/

4.配置環境變量,編輯/etc/profile文件,添加如下代碼
export MAVEN_HOME=/usr/local/apache-maven-3.0.3
export PATH=${PATH}:${MAVEN_HOME}/bin

5.保存文件,並運行如下命令使環境變量生效
source /etc/profile

6.在控制台輸入如下命令,如果能看到Maven相關版本信息,則說明Maven已經安裝成功
mvn -version

Linux中搭建本地倉庫
1. 下載nexus
下載最新版nexus(到目前為止最新版為nexus-2.7.0-05,下載地址http://www.sonatype.org/nexus/go,得到nexus-latest-bundle.tar.gz
2. 下載完成後將nexus-latest-bundle.tar.gz拷貝到/usr/local/目錄下,並進入/usr/local目錄
sudo cp nexus-latest-bundle.tar.gz /usr/local/
cd /usr/local
3. 解壓nexus-latest-bundle.tar.gz,得到nexus-2.7.0-05和sonatype-work,並做一個軟鏈接
tar -zxvf nexus-latest-bundle.tar.gz
4.運行nexus
./bin/nexus start
5、測試
在浏覽器中訪問:localhost:8081/nexus ,輸入用戶名與密碼(默認的admin、admin123)就可以管理自己的maven本地倉庫了

如果安裝成功但在浏覽器中訪問不了(訪問默認地址:http://localhost:8081/nexus),通過查看wrapper.log日志可能會看到“Unable to start java JVM:No such file or directory",
此時需要將wrapper.conf文件裡面的wapper.java.command=java修改成wapper.java.command=%JAVA_HOME%/bin/java(就是安裝jdk所在的文件路徑);
下面說下我在安裝後啟動時遇到的問題:
1. Unable to start java JVM:No such file or directory,解決方法,修改wapper.conf配置文件裡面的wapper.java.command。我開始修改成wapper.java.command={JAVA_HOME}/bin/java,但根本不起作用,看網上很我資料也說是改成那樣,最後無意中看到一篇文章(具體是哪篇忘記了)說是改wapper.java.command=%JAVA_HOME%/bin/java,要用%%而不是用{}。
2.還有一個問題就是啟動時報如下異常
/usr/local/nexus$ ./bin/nexus console
Running Nexus OSS...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2013-12-31 20:07:56 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Starting with arguments: [./conf/jetty.xml]
jvm 1 | 2013-12-31 20:07:56 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - JVM ID: 1, JVM PID: 2594, Wrapper PID: 2592, User: linming
jvm 1 | 2013-12-31 20:07:56 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Current directory: /usr/local/nexus-2.7.0-05
jvm 1 | 2013-12-31 20:07:57 INFO [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Temp directory: /usr/local/sonatype-work/nexus/tmp
jvm 1 | 2013-12-31 20:07:57 ERROR [WrapperListener_start_runner] - org.sonatype.nexus.bootstrap.jsw.JswLauncher - Failed to start
jvm 1 | java.nio.file.AccessDeniedException: /usr/local/sonatype-work/nexus/tmp
jvm 1 | at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[na:1.7.0_07]
jvm 1 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[na:1.7.0_07]
jvm 1 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[na:1.7.0_07]
jvm 1 | at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:382) ~[na:1.7.0_07]
jvm 1 | at java.nio.file.Files.createDirectory(Files.java:628) ~[na:1.7.0_07]
jvm 1 | at java.nio.file.Files.createAndCheckIsDirectory(Files.java:732) ~[na:1.7.0_07]
jvm 1 | at java.nio.file.Files.createDirectories(Files.java:718) ~[na:1.7.0_07]
jvm 1 | at org.sonatype.nexus.bootstrap.Launcher.ensureTmpDirSanity(Launcher.java:247) ~[nexus-bootstrap-2.7.0-05.jar:2.7.0-05]
jvm 1 | at org.sonatype.nexus.bootstrap.Launcher.start(Launcher.java:95) ~[nexus-bootstrap-2.7.0-05.jar:2.7.0-05]
解決方法:
sudo chmod -R 777 sonatype-work/nexus

3、報錯
****************************************
WARNING – NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.


大概意思就是要在環境配置export RUN_AS_USER=root,臨時配置

在命令行下輸入:

export RUN_AS_USER=root

然後執行,就不會再提示了
./nexus start

http://www.bkjia.com/Linuxjc/1196643.htmlwww.bkjia.comtruehttp://www.bkjia.com/Linuxjc/1196643.html

Copyright © Linux教程網 All Rights Reserved