java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

后端 未结 4 1122
无人共我
无人共我 2020-12-15 05:57

I am unable to find answer through the following links

One Two Three

Following is my pom.xml dependency


        <         


        
相关标签:
4条回答
  • 2020-12-15 06:35

    Decided to write solution in this topic, cause all suggestions above didn't help me. I had the same error, and I used spring-cloud-starter-netflix-eureka-client and resteasy-jackson2-provider. First dependency uses jax-rs 1.0, while the second one uses jax-rs 2.0, so this is the reason of conflict, as already said. I just refer to solution, cause it's not mine, but could help you:

    Eureka Client dependency update to Jersey 2.x

    Eureka and Jersey 2.x

    Solution:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        <exclusions>
            <exclusion>
              <groupId>javax.ws.rs</groupId>
              <artifactId>jsr311-api</artifactId>
           </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    
    0 讨论(0)
  • 2020-12-15 06:38

    It can be solved by excluding the jar as defined below, as JSR jar is conflicting with JAX-RS and creating the above error

    <dependency>
     <groupId>javax.ws.rs</groupId>
     <artifactId>jsr311-api</artifactId>
     <version>1.1</version>
     <scope>provided</scope>
    </dependency>
    

    Please remove it and run, it worked for me and i hope it will work for u too.

    0 讨论(0)
  • 2020-12-15 06:44

    java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

    The Application#getProperties() method was introduced in JAX-RS 2.0. And this error typically happens when you mix JAX-RS 1.x and JAX-RS 2.x.

    So check the JARs on your classpath and remove everything that relates to JAX-RS 1.x (and Jersey 1.x).

    Once you are using Maven, you can run mvn dependency:tree and check what's going on with your dependencies.


    I also see a few things that may cause some headaches:

    1. See below the correct Servlet API dependency for Tomcat 8 (don't forget the provided scope):

      <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.1</version>
          <scope>provided</scope>
      </dependency>
      
    2. Ensure that all Jersey dependencies use the same version.

    3. You probably don't need the javax.ws.rs-api, jersey-server and jersey-common dependencies.

      • Use jersey-container-servlet, jersey-media-json-jackson and jersey-media-multipart dependencies.

      • The jersey-container-servlet dependency uses javax.ws.rs-api, jersey-server and jersey-common as transitive dependencies.

    4. You probably don't need <type>jar</type> in your dependencies.

    0 讨论(0)
  • 2020-12-15 06:46

    I agree with Cassio. There are a couple of things I would add:

    • The dependency for me existed in jersey-core.
    • I could only see the hierarchal dependency in mvn dependency:tree. I may have missed it, but it was not showing up in the Eclipse hierarchy tree view.
    0 讨论(0)
提交回复
热议问题