Nexus OSS 系统搭建

来源:互联网 发布:水准仪测量数据图片 编辑:程序博客网 时间:2024/06/05 16:25

  1. 下载Nexus OSS. 
  2. 从sonatype下载.本次我们下载的是zip包. 
    1. 注意一点,如果想搭建maven的本地库需要2.X版本,而不是3.X版本
  3. 设置JDK。

    Nexus Repository Manager requires a Java 8 Runtime Environment (JRE) from Oracle.

    如果有多个jdk或者jre的时候,需要在脚本中设置.

    To set the path for a specific Java location open the bin/nexus script and locate the line INSTALL4J_JAVA_HOME_OVERRIDE. Remove the hash and specify the location of your JDK/JRE.

  4. 解压下载的压缩包。 
    因为我们本地的是1.6,但是我们有1.8,所以修改nexus的配置文件。对应到windows的是%nexus_home%/bin/nexus.vmoptions.我们可以增加一个参数:

    -vmE:/Program Files/Java/jdk1.8.0_40/bin
    • 1
    • 2
    • 1
    • 2
  5. 启动nexus oss。

    nexus.exe /run......<hr />Started Sonatype Nexus OSS 3.0.0-03<hr />
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
  6. 使用页面访问,默认的访问地址是:http://localhost:8081/,可以匿名访问,也可以使用默认的用户名和密码访问,admin/admin123

  7. 接下来我们就可以集成Maven了。 
    可以从Sonatype上的github上下载例子,然后导入到eclipse中。 
    根据那个我们修改我们原来的setting.xml。这是client的配置,oss nexus我们使用了默认的存储。在2.0的时候,server使用的是文件,但是在3.0时候换成blob,就算是host的repository,存储也要使用blob。

    <?xml version="1.0" encoding="UTF-8"?><settings>    <localRepository>E:\software\apache-maven-3.2.3\repo</localRepository>  <mirrors>    <mirror>      <!--Send all requests to the public group -->      <id>nexus</id>      <mirrorOf>*</mirrorOf>      <url>http://localhost:8081/repository/maven-public/</url>    </mirror>  </mirrors>  <activeProfiles>    <!--make the profile active all the time -->    <activeProfile>nexus</activeProfile>  </activeProfiles>  <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>  <pluginGroups>    <pluginGroup>org.sonatype.plugins</pluginGroup>  </pluginGroups>  <servers>    <server>      <id>nexus</id>      <username>admin</username>      <password>admin123</password>    </server>  </servers></settings>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
  8. 然后我们就可以在eclipse中导入simple project,之后看pom.xml配置的依赖能否正常下载。

问题总结:

  1. 在eclipse的选择maven->update project时候,发现还是提示missing jar之类的错误,不能下载。查了好多网页,都说是防火墙的问题。后来看setting中的repository地址有点不太像,放到chrome一访问,果断提示404.更改repository之后就好了. 
    具体报的错误是: 

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-help-plugin:2.2:system (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-help-plugin:2.2:system failed: Plugin org.apache.maven.plugins:maven-help-plugin:2.2 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-help-plugin:jar:2.2 -> org.apache.maven.plugin-tools:maven-plugin-tools-api:jar:2.4.3: Failed to read artifact descriptor for org.apache.maven.plugin-tools:maven-plugin-tools-api:jar:2.4.3: Failure to find org.apache.maven:maven-parent:pom:8 in `http://127.0.0.1:8081/nexus/content/groups/public` was cached in the local repository, resolution will not be reattempted until the update interval of roger-nexus has elapsed or updates are forced -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-help-plugin:2.2:system (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-help-plugin:2.2:system failed: Plugin org.apache.maven.plugins:maven-help-plugin:2.2 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-help-plugin:jar:2.2 -> org.apache.maven.plugin-tools:maven-plugin-tools-api:jar:2.4.3 

    测试方法:打开eclipse的maven->debug maven output,然后执行maven的maven test.
  2. 注意一点,如果想搭建maven的本地库需要2.X版本,而不是3.X版本