简体   繁体   English

生成失败-无法解析项目XYZ的依赖项

[英]MAVEN BUILD FAILURE - Could not resolve dependencies for project XYZ

I am integrating jersey and spring, for which I have following dependencies, but I am unable to build due to following error: 我正在集成jersey和spring,对此我具有以下依赖性,但是由于出现以下错误而无法构建:

My POM file: 我的POM文件:

<dependencies>

        <!-- Jersey -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>

        <!-- Spring 3 dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>1.8</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>

CONSOLE SCREEN SAYS: 控制台屏幕说:

Failed to execute goal on project SpringRestMavenCalc: Could not resolve dependencies for project SpringRestMavenCalc:SpringRestMavenCalc:war:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.sun.jersey:jersey-server:jar:1.8 (compile), org.springframework:spring-core:jar:3.0.5.RELEASE (compile), org.springframework:spring-context:jar:3.0.5.RELEASE (compile), org.springframework:spring-web:jar:3.0.5.RELEASE (compile), com.sun.jersey.contribs:jersey-spring:jar:1.8 (compile)]: No versions available for org.springframework:spring-aop:jar:[2.5.2,3) within specified range -> [Help 1] 无法在项目SpringRestMavenCalc上执行目标: 无法解析项目 SpringRestMavenCalc:SpringRestMavenCalc:war:0.0.1-SNAPSHOT的依赖项:无法为[com.sun.jersey:jersey-server:jar:1.8(compile),org)收集依赖项.springframework:spring-core:jar:3.0.5.RELEASE(编译),org.springframework:spring-context:jar:3.0.5.RELEASE(编译),org.springframework:spring-web:jar:3.0.5 .RELEASE(编译),com.sun.jersey.contribs:jersey-spring:jar:1.8(编译)]: 在指定范围内没有适用于org.springframework:spring-aop:jar:[2.5.2,3)的版本 -> [帮助1]

Is this versions problem ? 这是版本问题吗?

try adding maven dependency for spring-aop with the below: 尝试使用以下内容为spring-aop添加maven依赖项:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>2.5.2</version>
</dependency>

or 要么

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>3.0.5.RELEASE</version>
</dependency>

i guess one of this should work 我猜这应该工作

No versions available for org.springframework:spring-aop:jar:[2.5.2,3) 没有适用于org.springframework:spring-aop:jar:[2.5.2,3)的版本

Meaning jersey-spring needs spring-aop 2.5<= version < 3 表示平纹针织物-弹簧需要spring-aop 2.5 <=版本<3

So jersey-spring 1.8 and spring 3.0.5 are incompatible 因此运动衫-春季1.8和春季3.0.5不兼容

I would try the following: 我会尝试以下方法:

  1. Look for newer version of jersey-spring that works with spring 3.0.5. 寻找适用于Spring 3.0.5的较新版本的jersey-spring。 Maybe jersey-spring3 as suggested by peeskillet above. 也许是peeskillet所建议的jersey-spring3。
  2. Try my luck with spring 3.0.5 by adding exclusions to jersey-spring dependency. 通过在jersey-spring依赖项中添加排除项来尝试Spring 3.0.5的运气。 Consult the pom here and including them with version 3.0.5 if needed. 请在此处查阅pom 并在需要时将其包含3.0.5版。

Thanks All for your answers, Learnt lot from your answers. 谢谢大家的回答,从中学到了很多东西。

BUT FOLLOWING CHANGE IN MY POM MADE MY CODE RUN: 但随着我的代码运行更改,我的POM:

Addition of , 外加的 ,

<exclusion>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
</exclusion>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM