不支持Spring oauth2 oauth/token http 405错误POST方法

不支持Spring oauth2 oauth/token http 405错误POST方法,spring,security,spring-security-oauth2,Spring,Security,Spring Security Oauth2,我在Tomcat8(linux)上面临oauth/token的HTTP 405错误,而其他POST请求工作正常 上述问题不会出现在windows本地主机tomcat 8上 有什么线索吗 谢谢在添加以下依赖项后,我的问题得到了解决: @Bean public FrameworkEndpointHandlerMapping endpointHandlerMapping() { return new FrameworkEndpointHandlerMapping();

我在Tomcat8(linux)上面临oauth/token的HTTP 405错误,而其他POST请求工作正常

上述问题不会出现在windows本地主机tomcat 8上

有什么线索吗


谢谢

在添加以下依赖项后,我的问题得到了解决:

  @Bean
    public FrameworkEndpointHandlerMapping endpointHandlerMapping() {
        return new FrameworkEndpointHandlerMapping();
    }

令牌端点bean有一个允许的HttpMethods列表。默认值现在只是HttpMethod.POST。在创建令牌端点bean之后调用setAllowedRequestMethods可以解决这个问题。我这样做是为了在一个项目中修复它:

@Configuration
public class OAuth2ProviderTokenGetAllowedBackwardsCompatible implements InitializingBean
{
    @Autowired
    private TokenEndpoint tokenEndpoint;

    @Override
    public void afterPropertiesSet() {
        tokenEndpoint.setAllowedRequestMethods(new HashSet<HttpMethod>() {{
            add(HttpMethod.GET);
            add(HttpMethod.POST);
        }});
    }
}
@配置
公共类OAuth2ProviderTokenGetAllowedBackardsCompatible实现了InitializingBean
{
@自动连线
私有令牌端点令牌端点;
@凌驾
公共无效afterPropertiesSet(){
setAllowedRequestMethods(新的HashSet(){{
添加(HttpMethod.GET);
添加(HttpMethod.POST);
}});
}
}

我也遇到了同样的问题,它是由我用来将所有端点映射到其他对象的控制器方法引起的,即:

@GetMapping("**")
解决了将所有匹配终结点更改为的问题:

@GetMapping("/dev/**")