简体   繁体   中英

Got error after upgrade spring-web version

I got error after upgrade the spring-web version to after 6.0.0, previous is 5.3.20

 <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>6.0.4</version>
      </dependency>
Cannot access 'status': it is invisible (private in a supertype) in 'ResponseStatusException'

is ResponseStatusException -> {
                    serverWebExchange.response.statusCode = throwable.status
         }

In spring 5.3.x ResponseStatusException used to have getStatus() available directly as you can see in the java dochttps://docs.spring.io/spring-framework/docs/5.3.x/javadoc-api/

In version 6.0.x it was changed and ResponseStatusException extends from ErrorResponseException which does not have the getStatus() method directly available.

Instead, you need to call responseStatusException.getBody().getStatus() in order to access the status correctly. Check the java doc for details https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/ErrorResponseException.html

From your question it is not clear if you access status directly in your code or if this code is part of some library. If it is part of the library, then you would need to upgrade the version of the library to the one compatible with spring 6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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