码云地址:https://gitee.com/lpxs/lp-springcloud.git
有问题可以多沟通:136358344@qq.com。

由于使用Enableoauth2sso注解一直报错,报错原因见上一篇文章《springboot2集成oauth2坑一》
后面换成了@EnableOAuth2Client注解,并自定义了相关配置

 @Bean
public FilterRegistrationBean oauth2ClientFilterRegistration(OAuth2ClientContextFilter filter) {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(filter);
registration.setOrder(-100);
return registration;
} @Bean
@ConfigurationProperties("security.oauth2")
public ClientResources trina() {
return new ClientResources();
}

启动后会报下面错误:

Description:

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

Action:

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

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

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

springboot2集成oauth2坑二(The bean 'scopedTarget.oauth2ClientContext', defined in class path resource )的更多相关文章

  1. Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案

    ​ 项目是集成了Spring Boot和Spring Data,然后昨天简单Jpa和Spring Boot配置完成,开始进行公司项目的重构,然后出现了这个问题.当时是在网上找了好久.后来发现时java ...

  2. 【报错】org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSocketHandlerMapping' defined in class path resource

    环境:maven+eclipse+jdk1.8 [tomcat使用的是maven自带的插件,实质原因就是出在tomcat版本问题] 背景:在进行SSM集成WebSocket的时候,项目启动报org.s ...

  3. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  4. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'r ...

  5. MyBatis笔记----(2017年)最新的报错:Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in class path resource [com/ij34/mybatis/applicationContext.xml]; nested e

    四月 05, 2017 4:56:11 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRef ...

  6. MyBatis笔记----报错:Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/ij34/mybatis/applicationContext.xml]: Invocation of init method failed; nested exception is org.sp

    四月 05, 2017 4:51:02 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRef ...

  7. Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource

    我们在SpringBoot中用Jedis来访问Redis,其中Redis是采用集群(单机没有本篇文章的问题)的方式,在启用Redis的时候碰到如上问题. 错误的核心信息如下: Error creati ...

  8. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined ...

  9. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...

  10. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable t

    spring与hibernate整合然后出现如下错误: org.springframework.beans.factory.BeanCreationException: Error creating ...

随机推荐

  1. 苹果应用商店上传应用卡在了“Authenticating with the iTunes Store”

    在终端中依次运行下面代码 cd ~ mv .itmstransporter/ .old_itmstransporter/ "/Applications/Xcode.app/Contents/ ...

  2. Android/SELinux 添加 AVC 权限

    Android/SELinux 添加 AVC 权限 背景 在Android应用层中编写c/c++应用时,发现接口调用出现问题,logcat才知道是因为:权限不够. type=1400 audit(0. ...

  3. Linux系统获取开发板的文件系统并打包成img文件

    应用情形: 在实际的开发中,由于原系统包含的功能有限,而根据项目的需要,安装了相应的库及运行项目程序所创建的各种文件,和所做 的各种配置,想将调试好的系统打包发布,进行批量生产,就可参考本文提供的方法 ...

  4. 价破天荒!99元国产ARM工业“评估板”再袭,14天限量抢购!

    上线即爆款!2000家企业选择! 凭借"79元超高性价比"."双核A7@1.2GHz"."国产化率100%"."ARM + DSP ...

  5. TI AM64x工业核心板硬件说明书(双核ARM Cortex-A53 + 单/四核Cortex-R5F + 单核Cortex-M4F,主频1GHz)

    1          硬件资源 创龙科技SOM-TL64x是一款基于TI Sitara系列AM64x双核ARM Cortex-A53 + 单/四核Cortex-R5F + 单核Cortex-M4F设计 ...

  6. SqlCel 和MySQL for Excel在批量处理数据上的优劣

    先放MySQL for Excel编辑数据的界面, 理论上可以批量修改数据....但是: 百度翻译如下: 更改不被允许.....[经测试,64位的Excel出现同样的情况] 转换思路:不使用公式去匹配 ...

  7. 【ClickHouse】5:clickhouse集群部署

    背景介绍: 有三台CentOS7服务器安装了ClickHouse HostName IP 安装程序 程序端口 centf8118.sharding1.db 192.168.81.18 clickhou ...

  8. ABC195E

    其实我们发现很多博弈论的动态规划都是从后往前的,比如过河卒和本题. 这是因为从某种角度上来说这些动态规划有后效性而无前效性. 所以设计状态 \(dp_{i,j}\) 表示第 \(i\) 次操作 \(T ...

  9. yb课堂之用户注册登陆模块《六》

    用户注册功能接口开发 注册接口开发 MD5加密工具类封装 UserMapper.xml <?xml version="1.0" encoding="UTF-8&qu ...

  10. 洛谷P1790

    这道题可以说也是非常有意思的数学题,并且坑点也是非常多 刚开始以为是连通块的问题,后面发现没有那么简单,因为必须要分成两个部分才行,连通块可能会分成三个部分 后面想到利用割痕来解决,以为唯一的一种分割 ...