Spring Jersey-java.lang.NoSuchMethodError:javax.ws.rs.core.Application.getProperties()Ljava/util/Map [英] Spring Jersey - java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map

查看:130
本文介绍了Spring Jersey-java.lang.NoSuchMethodError:javax.ws.rs.core.Application.getProperties()Ljava/util/Map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:因此,我只想指出,在提交此问题之前,我尝试过在类似的stackoverflow问题(例如

UPDATE: So I just want to point out that before I submitted this question, I attempted the solution that I've seen on similar stackoverflow questions such as this one. It was still giving me runtime errors, so I decided to write this question. mvn dependency:tree is what I was looking for so thanks @dunni. With mvn dependency:tree, I was able to find the actual name of the jersey dependency that was breaking my application and updated the exclusion by changing it from:

<exclusions>
    <exclusion>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
    </exclusion>
</exclusions>

收件人:

<exclusions>
    <exclusion>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
    </exclusion>
</exclusions>

现在可以使用.

在最长的时间内,我一直在使用1个内部公司存储库来开发此Spring Jersey REST应用程序.现在,我发现我只需要使用一个库就在第二个公司内部资源库中.我更新了.m2-> settings.xml配置,以将对新存储库的引用添加为:

For the longest time, I've been working on this Spring Jersey REST application using 1 internal company repository. Now, I found out that a library I need to use only exists in a 2nd internal company repository. I updated my .m2 -> settings.xml configuration to add the reference to the new repo like so:

<settings>
    <mirrors>
        <mirror>
            <id>internal-repository1</id>
            <name>name</name>
            <url>http://repo1.company.com/repositories/</url>
            <mirrorOf>*, !repo2</mirrorOf>
        </mirror>
    </mirrors>  
    <profiles>
        <profile>
            <id>profile</id>
            <repositories>
                <repository>
                    <id>repo1</id>
                    <name>repo1</name>
                    <url>http://repo1.company.com/repositories/</url>
                </repository>
                <repository>
                    <id>repo2</id>
                    <name>repo2</name>
                    <url>http://repo2.company.com/respositories/</url>
                </repository>
            </repositories>
        </profile>                
    </profiles>

    <activeProfiles>
        <activeProfile>profile</activeProfile>
    </activeProfiles>
</settings>

这有效.我可以在System.out中看到它尝试从repo1.company.com/repositories/下载repo2独占依赖项.它失败,然后尝试从repo2.company.com/repositories下载它,然后成功.构建继续进行,最终tomcat在localhost:8080上启动,一切都很好.

This works. I can see in the System.out that it attempts to download the repo2 exclusive dependency from repo1.company.com/repositories/. It fails, then it attempts to download it from repo2.company.com/repositories and it succeeds. The build continues, and eventually tomcat gets started up on localhost:8080 and everything is fine.

问题是,每当我尝试访问已设置的任何Jersey REST端点时,都会收到问题标题中提到的运行时错误:

The problem is, whenever I try to access any of my Jersey REST endpoints I've set up, I get the runtime error mentioned in the question title:

ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[my.package.name] 
- Allocate exception for servlet my.package.name.JerseyConfig
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

我知道问题出在我要使用的新依赖项中.当我在pom.xml中注释掉依赖项并重新运行该应用程序时,一切正常.所有REST端点均正常运行.取消注释依赖项,重新运行应用程序,然后尝试访问我的REST端点,然后出现上述错误.

I know for a fact that the issue lies somewhere in this new dependency I'm trying to use. When I comment out the dependency in my pom.xml, and re run the application, everything works fine. All REST endpoints are functional. Uncomment the dependency, re-run the application, and try to access my REST endpoints, and I get the above error.

我该如何找出这种依赖性为什么会在运行时破坏我的Jersey应用程序?

How do I go about finding out why this dependency is breaking my Jersey application at runtime?

推荐答案

看到错误,我可以猜测jar文件中存在一些冲突.请检查您是否同时拥有JAX-RS 1和JAX-RS 2 jar在类路径上.泽西岛2使用JAX-RS 2(javax.ws.rs-api-2.0.1.jar),但是如果您也有jsr311-api.jar,即JAX-RS 1,则有一个javax.ws.rs .core.Application在每个jar中.但是jsr311-api应用程序没有方法getProperties().

By Seeing the error I can guess that there are some conflicts in jar files Please check if you have a both a JAX-RS 1 and JAX-RS 2 jar on the classpath. Jersey 2 uses JAX-RS 2 (javax.ws.rs-api-2.0.1.jar), but if you have the jsr311-api.jar also, which is JAX-RS 1, there is a javax.ws.rs.core.Application in each jar. But the jsr311-api Application doesn't have the method getProperties().

这篇关于Spring Jersey-java.lang.NoSuchMethodError:javax.ws.rs.core.Application.getProperties()Ljava/util/Map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆