MAVEN构建失败——不能解决项目XYZ的依赖关系。

时间:2022-09-03 22:53:32

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的依赖关系。释放(编译),org.springframework:spring上下文:jar:3.0.5。释放(编译),org.springframework:spring web:jar:3.0.5。发布(编译),com.sun. jersey.com/: jersey-spring:jar:1.8(编译):没有版本可用于org.springframework:spring-aop:jar:[2.5.2,3)在指定范围内->[帮助1]

Is this versions problem ?

这个版本有问题吗?

3 个解决方案

#1


0  

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

我想其中一个应该管用。

#2


0  

No versions available for org.springframework:spring-aop:jar:[2.5.2,3)

springframework:spring-aop:jar:[2.5.2,3)

Meaning jersey-spring needs spring-aop 2.5<= version < 3

意味着jersey-spring需要spring-aop 2.5<=版本< 3。

So jersey-spring 1.8 and spring 3.0.5 are incompatible

所以jersey-spring 1.8和spring 3.0.5是不兼容的。

I would try the following:

我会尝试以下几点:

  1. Look for newer version of jersey-spring that works with spring 3.0.5. Maybe jersey-spring3 as suggested by peeskillet above.
  2. 寻找新版本的jersey-spring,它适用于spring 3.0.5。也许像peeskillet所建议的jersey-spring3。
  3. Try my luck with spring 3.0.5 by adding exclusions to jersey-spring dependency. Consult the pom here and including them with version 3.0.5 if needed.
  4. 通过添加对jersey-spring依赖性的排除,来试试我在spring 3.0.5上的运气。如果需要,请参考这里的pom,并将它们包含在3.0.5版本中。

#3


0  

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>

#1


0  

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

我想其中一个应该管用。

#2


0  

No versions available for org.springframework:spring-aop:jar:[2.5.2,3)

springframework:spring-aop:jar:[2.5.2,3)

Meaning jersey-spring needs spring-aop 2.5<= version < 3

意味着jersey-spring需要spring-aop 2.5<=版本< 3。

So jersey-spring 1.8 and spring 3.0.5 are incompatible

所以jersey-spring 1.8和spring 3.0.5是不兼容的。

I would try the following:

我会尝试以下几点:

  1. Look for newer version of jersey-spring that works with spring 3.0.5. Maybe jersey-spring3 as suggested by peeskillet above.
  2. 寻找新版本的jersey-spring,它适用于spring 3.0.5。也许像peeskillet所建议的jersey-spring3。
  3. Try my luck with spring 3.0.5 by adding exclusions to jersey-spring dependency. Consult the pom here and including them with version 3.0.5 if needed.
  4. 通过添加对jersey-spring依赖性的排除,来试试我在spring 3.0.5上的运气。如果需要,请参考这里的pom,并将它们包含在3.0.5版本中。

#3


0  

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>