springboot2集成oauth2的示例分析

发布时间:2021-10-19 15:56:10 作者:柒染
来源:亿速云 阅读:118

今天就跟大家聊聊有关springboot2集成oauth2的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

@EnableOAuth3Client注解,并自定义了相关配置

 @Bean
    public FilterRegistrationBean oauth3ClientFilterRegistration(OAuth3ClientContextFilter filter) {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(filter);
        registration.setOrder(-100);
        return registration;
    }

    @Bean
    @ConfigurationProperties("security.oauth3")
    public ClientResources trina() {
        return new ClientResources();
    }

启动后会报下面错误:

Description:

The bean 'scopedTarget.oauth3ClientContext', defined in class path resource [org/springframework/boot/autoconfigure/security/oauth3/client/OAuth3RestOperationsConfiguration$SessionScopedConfiguration$ClientContextConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/security/oauth3/config/annotation/web/configuration/OAuth3ClientConfiguration$OAuth3ClientContextConfiguration.class] and overriding is disabled.

Action:

这个有两种方案: 1、去掉autoconfig依赖spring-security-oauth3-autoconfigure 2、使用@EnableAutoConfiguration来排除掉oauth3相关自动装配,这个得根据具体报错信息来。 如下:

@EnableAutoConfiguration(exclude = {
        org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
})

3、增加配置spring.main.allow-bean-definition-overriding =true

看完上述内容,你们对springboot2集成oauth2的示例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

推荐阅读:
  1. Springboot2中怎么集成pagehelper
  2. iOS集成GoogleMap的示例分析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

springboot oauth

上一篇:springcloud集成grpc是怎样的

下一篇:java高并发中线程不安全类与写法是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》