1

Request:

    @Headers("userId: {userId}")
    @RequestMapping(method = RequestMethod.GET, value = "/token")
    String getToken(@RequestHeader(name = "userId") Long userId);

Handler:

    @GetMapping("/token")
    public ResponseEntity<?> getToken(@RequestHeader String userId) throws NoSuchAlgorithmException, InvalidKeySpecException {
        String token = jwtAuth.generateToken(userId);
        return ok(token);
    }

Exception:

java.lang.AbstractMethodError: Receiver class org.springframework.cloud.openfeign.support.SpringDecoder$FeignResponseAdapter does not define or inherit an implementation of the resolved method 'abstract org.springframework.http.HttpStatusCode getStatusCode()' of interface org.springframework.http.client.ClientHttpResponse.

Not sure what I'm doing wrong here. I can post full stacktrace if needed

OpenFeign version is 3.1.5 Springboot 3

dev-rifaii
  • 217
  • 2
  • 9

4 Answers4

5

It seems that the spring-boot and spring-cloud versions are not aligned. For spring boot 3.X you can use spring cloud version 2022.0.x.

Please note that this is different than the OpenFeign version.

<properties>
    <spring-cloud.version>2022.0.1</spring-cloud.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

For more details, Please visit: https://spring.io/projects/spring-cloud.

  • After doing this I had to change my spring boot version to 3.0.x and spring-cloud-openfeign version to 4.0.1. https://github.com/spring-cloud/spring-cloud-openfeign/issues/803#issuecomment-1346410680 – Olayiwola Osho Mar 28 '23 at 13:48
1
<properties>
    <java.version>17</java.version>
    <spring-cloud.version>2022.0.1</spring-cloud.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Spring boot 3.X, 2022.0.X feign version should be used

0

You need to use OpenFeign version is 4.0.3 Springboot 3.x

Mamidi
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 25 '23 at 21:00
0

You need to use OpenFeign version 4.0.3 Springboot 3.x

mamidi
  • 1