1、首先下载nexus,下载地址是http://www.sonatype.org/nexus/go,在此页面可以下载最新版本的Nexus;

2、解压下载的zip包,安装Nexus,由于下载的zip包自带jetty,在cmd命令模式下 到Nexus的安装目录,执行命令nexus.bat install命令安装nexus

3、然后运行nexus.bat start命令启动nexus(其他命令有nexus.bat stop停止 nexus.bat restart重启 nexus.bat uninstall卸载)


在浏览器地址栏输入http://localhost:8080/nexus/即进入nexus首页。有管理nexus要以管理员身份登录,点击首页右上角的login输入默认登录名、密码admin/admin123即可登录。

登录系统后点击左侧菜单栏Views/Repositories下的Repositories选择Central仓库点击下边的Configuration把Download Remote Indexes属性设为True保存即可。


自建maven仓库 和使用 搭建maven私有仓库_自建maven仓库 和使用

然后在Central仓库上右键然后点击Repair Index 即可下载中心仓库的索引文件,稍等几分钟点击下边的Browse Index即可看见下载的索引文件。


自建maven仓库 和使用 搭建maven私有仓库_自建maven仓库 和使用_02

往Public Repositories中添加Central仓库,点击Public Repositories在Configuration选项卡中把Central移到左侧即可。

 

自建maven仓库 和使用 搭建maven私有仓库_java_03

 

最后在自己的应用中把中心仓库配置成建立的私有仓库地址即可,修改本地的maven配置文件,C:\Documents and Settings\用户名\.m2\setting.xml



Nexus启动报错: Unsupported major.minor version 51.0

1.遇到问题

   今天搭建Nexus私服,出现了以前没遇到过的错误。

    a).采用console-nexus.bat开启报错:


wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    | java.lang.UnsupportedClassVersionError: org/sonatype/nexus/bootstrap/
jsw/JswLauncher : Unsupported major.minor version <span class="number" style="color: rgb(0, 153, 153);">51.0</span>
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.lang.ClassLoader.defineClass1(Native Method)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">631</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.lang.ClassLoader.defineClass(ClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">615</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.security.SecureClassLoader.defineClass(SecureClassLoader
.java:<span class="number" style="color: rgb(0, 153, 153);">141</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.net.URLClassLoader.defineClass(URLClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">283</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.net.URLClassLoader.access<span class="variable" style="color: rgb(0, 128, 128);">$0</span>0<span class="number" style="color: rgb(0, 153, 153);">0</span>(URLClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">58</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.net.URLClassLoader<span class="variable" style="color: rgb(0, 128, 128);">$1</span>.run(URLClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">197</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.security.AccessController.doPrivileged(Native Method)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.net.URLClassLoader.findClass(URLClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">190</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.lang.ClassLoader.loadClass(ClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">306</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at sun.misc.Launcher<span class="variable" style="color: rgb(0, 128, 128);">$AppClassLoader</span>.loadClass(Launcher.java:<span class="number" style="color: rgb(0, 153, 153);">301</span>)

jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    |      at java.lang.ClassLoader.loadClass(ClassLoader.java:<span class="number" style="color: rgb(0, 153, 153);">247</span>)
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    | Could <span class="keyword" style="font-weight: bold;">not</span> find the main class: org.sonatype.nexus.bootstrap.jsw.JswLa
uncher.  Program will <span class="keyword" style="font-weight: bold;">exit</span>.
jvm <span class="number" style="color: rgb(0, 153, 153);">1</span>    | Exception in thread <span class="string" style="color: rgb(221, 17, 68);">"main"</span>
wrapper  | JVM exited <span class="keyword" style="font-weight: bold;">while</span> loading the application.
wrapper  | Reloading Wrapper configuration...
wrapper  | Launching a JVM...


    b).采用install-nexus.bat、start-nexus.bat开启报错:

wrapper  | Starting the nexus service...
wrapper  | Waiting to <span class="operator"><span class="keyword" style="font-weight: bold;">start</span>...
wrapper  | Waiting <span class="keyword" style="font-weight: bold;">to</span> <span class="keyword" style="font-weight: bold;">start</span>...
wrapper  | Waiting <span class="keyword" style="font-weight: bold;">to</span> <span class="keyword" style="font-weight: bold;">start</span>...
wrapper  | The nexus service was launched, but failed <span class="keyword" style="font-weight: bold;">to</span> <span class="keyword" style="font-weight: bold;">start</span>.</span>

2.分析问题

   看日志的问题,大概就是版本存在问题,找不到Java虚拟机。

   Java版本:1.6.0_45

   Nexus版本: 2.7.2-03

   按照网上的办法是修改bin\jsw\conf\wrapper.conf中的wrapper.java.command


wrapper.java.command=C:\Lynch\Develop\Java\jdk1.6\bin\java.exe


   指向自己的jdk,似乎在特俗的Nexus版本可以解决,这里我还是不行。

3.解决问题

   最终查询文档得到思路


Sonatype Nexus 2.6.0 Java 6 Support EOL Oracle's support for Java 6 ended in February 2013. Consequentially as of version 2.6 Nexus now requires a Java 7 JRE to run.


Sonatype Nexus OSS <span class="number" style="color: rgb(0, 153, 153);">2.5</span><span class="number" style="color: rgb(0, 153, 153);">.0</span>

Java <span class="number" style="color: rgb(0, 153, 153);">6</span> Support <span class="keyword" style="font-weight: bold;">is</span> Deprecated
Java <span class="number" style="color: rgb(0, 153, 153);">6</span> reached Official EOL on February <span class="number" style="color: rgb(0, 153, 153);">2013.</span>  Since it <span class="keyword" style="font-weight: bold;">is</span> no longer receiving updates we are deprecating support <span class="keyword" style="font-weight: bold;">for</span> running Nexus <span class="keyword" style="font-weight: bold;">with</span> Java <span class="number" style="color: rgb(0, 153, 153);">6</span> <span class="keyword" style="font-weight: bold;">in</span> the <span class="number" style="color: rgb(0, 153, 153);">2.5</span> release, <span class="keyword" style="font-weight: bold;">and</span> will be removing it <span class="keyword" style="font-weight: bold;">in</span> the upcoming <span class="number" style="color: rgb(0, 153, 153);">2.6</span> release.
Sonatype Nexus <span class="number" style="color: rgb(0, 153, 153);">2.0</span> Release Notes

JDK <span class="number" style="color: rgb(0, 153, 153);">7</span> Support
Nexus <span class="number" style="color: rgb(0, 153, 153);">2.0</span> <span class="keyword" style="font-weight: bold;">is</span> the first version of Nexus verified to work <span class="keyword" style="font-weight: bold;">with</span> Java <span class="number" style="color: rgb(0, 153, 153);">7.</span> The recommended versions are

Oracle <span class="number" style="color: rgb(0, 153, 153);">7</span>u2 <span class="keyword" style="font-weight: bold;">or</span> later *
IBM Java <span class="number" style="color: rgb(0, 153, 153);">7.0</span> GA <span class="keyword" style="font-weight: bold;">or</span> later
* Note: Nexus <span class="number" style="color: rgb(0, 153, 153);">2.0</span> will <span class="keyword" style="font-weight: bold;">not</span> run on versions of Oracle Java <span class="number" style="color: rgb(0, 153, 153);">7</span> prior to <span class="number" style="color: rgb(0, 153, 153);">7</span>u2.

When running <span class="keyword" style="font-weight: bold;">with</span> Java <span class="number" style="color: rgb(0, 153, 153);">6</span> the recommended versions are:

Oracle Java <span class="number" style="color: rgb(0, 153, 153);">6</span>u30 <span class="keyword" style="font-weight: bold;">or</span> later
IBM Java <span class="number" style="color: rgb(0, 153, 153);">6.0</span><span class="number" style="color: rgb(0, 153, 153);">.10</span><span class="number" style="color: rgb(0, 153, 153);">.0</span> <span class="keyword" style="font-weight: bold;">or</span> Later

   a).Nexus的2.6版本及其以后版本

       使用的Java的jdk7.

   b).Nexus的2.0-2.5版本

       使用Java的jdk6的update30版本及其以后的jdk6版本

       使用Java的jdk7的update2版本及其以后jdk7版本

   c).最终解决方案

       升级jdk7(注意jdk的update版本,升级最新版本就可以)