ClassCastException NimbusJwtDecoder 无法转换为 NimbusJwtDecoderJwkSupport

ClassCastException NimbusJwtDecoder cannot be cast to NimbusJwtDecoderJwkSupport

我从 2.1.5

升级到 Spring boot 2.3.0 时出现 spring-security 错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.ClassCastException: org.springframework.security.oauth2.jwt.NimbusJwtDecoder cannot be cast to org.springframework.security.oauth2.jwt.NimbusJwtDecoderJwkSupport

我的安全配置是

public class OpenIdSecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    private OAuth2ResourceServerProperties resourceServerProperties;

    @Autowired
    private MyJwtValidator myJwtValidator;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        super.configure(http);

      http.authorizeRequests().anyRequest().authenticated().and()
                .oauth2ResourceServer().jwt().decoder(jwtDecoder())
                .jwtAuthenticationConverter(new MyAuthenticationConverter());
    }

    private JwtDecoder jwtDecoder() {

        String issuerUri = this.resourceServerProperties.getJwt().getIssuerUri();

        NimbusJwtDecoderJwkSupport jwtDecoder = (NimbusJwtDecoderJwkSupport) JwtDecoders
                .fromOidcIssuerLocation(issuerUri);

        OAuth2TokenValidator<Jwt> issuer = JwtValidators.createDefaultWithIssuer(issuerUri);
        OAuth2TokenValidator<Jwt> myIssuer = new DelegatingOAuth2TokenValidator<>(issuer, myJwtValidator);

        jwtDecoder.setJwtValidator(myIssuer);

        return jwtDecoder;
    }
}

我相信中间发生了一些变化,但我无法理解。
任何帮助或想法将不胜感激
谢谢!!

在 NimbusJwtDecoderJwkSupport 的状态下使用 NimbusJwtDecoder

https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/oauth2/jwt/NimbusJwtDecoder.html