posts - 167,  comments - 30,  trackbacks - 0

          maven大家都了解了是個什么玩意兒,直接上部署過程了。
          新建個目錄mkdir /data/maven, 
          進入該目錄并執行如下操作步驟:

          maven官網下載包:

          #wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz

           解壓maven

          # tar -zxvf apache-maven-3.1.1-bin.tar.gz

           進入apache-maven-3.1.1,新建隱藏目錄.m2(mkdir .m2),再在該.m2目錄下創建setting.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">

          <!-- 指定jar包存放路徑-->

          <localRepository>/data/maven/apache-maven-3.1.1/repo/</localRepository>

          <pluginGroups> </pluginGroups> <!--設置代理服務器 -->

          <proxies> <proxy>

          <id>my-proxy</id>

          <active>true</active>

          <protocol>http</protocol>

          <host>202.84.17.41</host>

          <port>8080</port>

          </proxy> </proxies>

          <!-- 設置私服server-->

          <servers>

          <server>

          <id>nexus</id>

          <username>admin</username>

          <password>admin</password>

          </server> </servers> <!-- 配置私服作為鏡像,只允許maven使用私服--> <mirrors>

          <mirror>

          <id>nexus</id>

          <mirrorOf>*</mirrorOf>

          <url>http://localhost:8081/nexus/content/groups/public</url>

          </mirror> </mirrors> <profiles>

          <profile>

          <id>nexus</id>

          <repositories>

          <repository>

          <id>central</id>

          <url>http://central</url>

          <releases><enabled>true</enabled></releases>

          <snapshots><enabled>true</enabled></snapshots>

          </repository>

          </repositories>

          <pluginRepositories>

          <pluginRepository>

          <id>central</id>

          <url>http://central</url>

          <releases><enabled>true</enabled></releases>

          <snapshots><enabled>true</enabled></snapshots>

          </pluginRepository>

          </pluginRepositories>

          </profile>

          </profiles>

          <activeProfiles>

          <activeProfile>nexus</activeProfile>

          </activeProfiles></settings>

           Nexus所有版本下載地址:http://www.sonatype.org/nexus/archived

          nexus官網下載最新的版本.

          # wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz

           解壓nexus

          # tar -zxvf nexus-2.6.4-02-bundle.tar.gz

           啟動腳本:

          mavenStart.sh

          #!/bin/bash

          M2_HOME=/data/maven/apache-maven-3.1.1

          JAVA_HOME=/usr/local/jdk/bin

          export M2_HOME

          PATH=$JAVA_HOME:$PATH:$HOME/bin:$M2_HOME/bin

          export PATH

          /data/maven/nexus-2.1.1/bin/jsw/linux-x86-64/nexus start

          停止腳本:

          mavenStop.sh

          #!/bin/bash

          /data/maven/nexus-2.1.1/bin/jsw/linux-x86-64/nexus stop

           正常啟動nexus

          # sh mavenStart.sh

          ****************************************

          WARNING - NOT RECOMMENDED TO RUN AS ROOT

          ****************************************

          Starting Nexus OSS...

          Started Nexus OSS.

          錯誤1:若出現如下錯誤:

          ***********************************

          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

          解決方式:修改$NEXUS_HOME/jsw/linuxx86-64/nexus文件中RUN_AS_USER=root

           錯誤2:啟動幾秒鐘后,自動停止了nexus進程,報錯如下:

          Launching a JVM...

          wrapper  | JVM exited while loading the application.

          jvm 3    | Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonatype/nexus/bootstrap/jsw/JswLauncher : Unsupported major.minor version 51.0

          jvm 3    |     at java.lang.ClassLoader.defineClass1(Native Method)

          jvm 3    |     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)

          jvm 3    |     at java.lang.ClassLoader.defineClass(ClassLoader.java:616)

          jvm 3    |     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

          jvm 3    |     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)

          jvm 3    |     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

          jvm 3    |     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)

          jvm 3    |     at java.security.AccessController.doPrivileged(Native Method)

          jvm 3    |     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

          jvm 3    |     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

          jvm 3    |     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

          jvm 3    |     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

          jvm 3    | Could not find the main class: org.sonatype.nexus.bootstrap.jsw.JswLauncher.  Program will exit.

          解決方式:可能原因是jdk版本低 沒有去下載jdk1.7,而是下載了nexus-2.1.1-bundle.tar.gz,測試了下,jdk1.6是完全支持滴~

           重新修改配置并啟動:

          瀏覽器中輸入:http://IP:8081/nexus

          顯示界面如下:


          默認用戶名和密碼:admin/admin123

          點擊左側 Repositories,顯示如下:

          將如下三項目中的Configuration中的Download Remote indexs修改為true
           

          然后,右鍵à選擇Repair Index Nexus遠程下載索引文件。


          3rd party Configuration中的Deploment Policy修改為Allow Redeploy

          以上就基本已將nexus私服配置完成。

          通過選擇Select Artifact(s) for upload,上傳單獨開發的jar包方式:



           二、 maven插件安裝及nexus私服的使用:

          我的電腦中以前已經安裝過maven了,在控制臺下輸入mvn -version可以查看到當前maven版本:


          修改D:\apache-maven-3.0.5\conf\setting.xml文件中變更maven repository地址。

          默認是在用戶本地臨時目錄下,我的是C:\Documents and Settings\server\.m2\repository

          配置修改如下:

          <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

             | The path to the local repository maven will use to store artifacts.

             |

             | Default: ~/.m2/repository

            <localRepository>/path/to/local/repo</localRepository>

            -->

            <localRepository>E:/maven/repo</localRepository>

            <!-- interactiveMode

             | This will determine whether maven prompts you when it needs input. If set to false,

             | maven will use a sensible default value, perhaps based on some other setting, for

             | the parameter in question.

             |

             | Default: true

            <interactiveMode>true</interactiveMode>

            -->

           控制臺下,運行mvn help:system, 從遠程倉庫下載..


          eclipse /Myeclipse安裝插件的方式最常見的有兩種:

              1. 一種是在線安裝,這,貌似是用的最多的,就是:Help  -->  Install New Software,然后輸入 HTTP 地址來安裝,但有一個很明顯的缺點,就是慢!
              2. 一種是離線安裝,用 link 的方式來安裝,這種方式可拔性更好,可以隨時將插件插上和拔下,非常方便。

          第二中方式可以參考博客:

          http://www.aygfsteel.com/fancydeepin/archive/2012/07/13/382965.html

          我比較傾向于使用Myeclipse高度集成化的工具.

          安裝成功后,工具中WindowsàPreferences


          安裝maven


           

          配置setting.xml


           以上配置完成后,現有maven工程pom.xml文件中修改nexus私服地址后,會自動下載依賴的jar,控制臺中不斷輸出信息:



          posted on 2013-11-19 11:48 David1228 閱讀(23752) 評論(1)  編輯  收藏 所屬分類: JAVA其他

          FeedBack:
          # re: Maven及Nexus私服搭建[未登錄]
          2015-09-28 17:27 | Ron
          謝謝,很有幫助!
          在2.11.1版本中,啟動文件路徑變為:nexus-2.11.1-01/bin/nexus  回復  更多評論
            

          <2013年11月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          文章檔案

          新聞分類

          新聞檔案

          相冊

          收藏夾

          Java

          Linux知識相關

          Spring相關

          云計算/Linux/虛擬化技術/

          友情博客

          多線程并發編程

          開源技術

          持久層技術相關

          搜索

          •  

          積分與排名

          • 積分 - 359229
          • 排名 - 154

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 宁国市| 西贡区| 哈密市| 宽甸| 大邑县| 巢湖市| 滦南县| 江阴市| 布尔津县| 丁青县| 肥东县| 大冶市| 南皮县| 甘孜县| 文化| 界首市| 新密市| 梨树县| 宜兴市| 望城县| 长顺县| 沂源县| 林州市| 富裕县| 象州县| 论坛| 霍城县| 凯里市| 汝阳县| 来安县| 玉龙| 合江县| 邯郸市| 翁源县| 谢通门县| 静安区| 平原县| 达拉特旗| 耿马| 兰坪| 神池县|