为什么我的maven项目没有从nexus中获取jar

时间:2016-03-21 12:13:31

标签: maven jenkins nexus

我在Redhat上,jenkins使用Nexus Repository Manager OSS 2.12.0-01

我想要实现的是从nexus下载所有jar。 什么,我已经完成了。 已成功安装nexus 2.12.0-01

这是我的专家setting.xml

的内容

<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">
 

    <mirrors>
        <mirror>
        <!--This sends everything else to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://localhost:8081/nexus/content/groups/public</url>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>nexus</id>
            <!--Enable snapshots for the built in central repo to direct -->
            <!--all requests to nexus via the mirror -->
            <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>
    <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings> 

在nexus 中成功安装了Ojdbc5的第三方jar enter image description here

我的父母pom的内容

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.abc</groupId>
  <artifactId>Test</artifactId>
  	<packaging>pom</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <modules>
    <module>Project1</module>
    <module>Project2</module>
 </modules>
 
 <distributionManagement>
    <snapshotRepository>
        <id>my-snapshots</id>
        <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>

    <repository>
        <id>my-releases</id>
        <url>http://localhost:8081/nexus/content/repositories/releases</url>
    </repository>

</distributionManagement>
</project>

在上面的pom.xml中,定义了两个项目。当我使用jenkins构建时,第一个项目成功构建。但第二个引发错误。

  

无法在项目项目2上执行目标:无法解决   项目的依赖项com.abc:project2:war:0.0.1-SNAPSHOT:失败   找到com.oracle:ojdbc5:jar:11.2.0.1 in   http://localhost:8081/nexus/content/groups/public被缓存在   本地存储库,在更新之前不会重新尝试解析   nexus的间隔已经过去或强制更新 - &gt; [帮助1]

请参阅project2 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.abc</groupId>
  <artifactId>project2</artifactId>
    <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Maven Webapp</name>
  <url>http://localhost:8081/nexus/content/repositories/releases</url>

 <distributionManagement>
  <repository>
    <id>thirdparty</id>
    <url>http://localhost:8081/nexus/content/repositories/thirdparty</url>
  </repository>
</distributionManagement>

  <dependencies>
        <!-- Spring ORM support -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.2.13.RELEASE</version>
        </dependency>

        <!-- Spring Batch -->
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-core</artifactId>
            <version>3.0.1.RELEASE</version>
        </dependency>

        <!-- ojdbc 5 dependency provide by nexus-->

        <dependency>
         <groupId>com.oracle</groupId>
         <artifactId>ojdbc5</artifactId>
         <version>11.2.0.1</version>
        </dependency>
    <!-- That is creating problem -->

             

请不要担心上述pom.xml我已经从pom中删除了很多依赖项以减少问题的大小。 pom结构是好的。

现在开始质疑。我错过了任何配置,为什么我得到

  

无法在项目gsdataprocessor上执行目标:无法解析项目com.globalss.batch的依赖项:gsdataprocessor:war:0.0.1-SNAPSHOT:未能在{{找不到com.oracle:ojdbc5:jar:11.2.0.1 3}}缓存在本地存储库中,在nexus的更新间隔已经过去或强制更新之前,不会重新尝试解析 - &gt; [帮助1]

此错误。 请帮忙

更新1:根据用户sanigo的建议,我已将Thirdpary存储库添加到公共存储库组

更新2:下面是显示oracle ojdbc5可用的屏幕短片是公共存储库。 http://localhost:8081/nexus/content/groups/public enter image description here

1 个答案:

答案 0 :(得分:5)

您的http://localhost:8081/nexus/content/groups/public(公共存储库组)是&#34; *&#34;的镜像,因此您应该将http://localhost:8081/nexus/content/repositories/thirdparty(Thirdparty repositoy添加到公共存储库组中,您可以在公共存储库配置选项卡。然后,您可以使用mvn -U clean install.