码云地址: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. kong网关部署

    软件版本: Postgresql:9.6 (不使用最新版,是因为 konga 不支持) Kong:3.4.2 konga:0.14.7 (UI管理界面) ### Postgresql部署 ## doc ...

  2. python 第一次主要是if while 奇偶数的练习

    例如输出1-10的数字,但是7除外. a=1 while a < 11: if a == 7: pass else: print(a) a=a+1 输出1-100所以的偶数 a=1 while ...

  3. 【Playwright+Python】手把手带你写一个自动化测试脚本

    ​ 如何使用代理方式打开网页 在 playwright.chromium.launch() 中传入 proxy 参数即可,示例代码如下: 1.同步写法: 1 from playwright.sync_ ...

  4. ZYNQ uboot 网络调试

    背景 使用 Vivado配置好网络,并在PetaLinux中构建了完整的uboot.kernel.rootfs以后,发现网络有问题. > ping 192.168.168.1 ethernet@ ...

  5. 化合物同位素理论同位素分布计算软件Isopro 3.0

    大家好,今天分享一款软件,即可以计算化合物理论同位素分布的软件Isopro 3.0.在做质谱的实验时,特别对合成的化合物进行质量表征时,往往要求ppm绝对值在5以内,对质谱的分辨率要求很高.对于小分子 ...

  6. 嵌入式工业开发板基础测试手册——基于NXP iMX6ULL开发板(1)

    前 言 本文档适用开发环境: Windows开发环境:Windows 7 64bit.Windows 10 64bit 虚拟机:VMware15.1.0 Linux开发环境:Ubuntu18.04.4 ...

  7. Redis缓存雪崩,击穿,穿透以及解决方案

    Redis读写过程 一般情况下,Redis都是作为client与MySQL间的一层缓存,尽量减少MySQL的读压力,数据流向如图所示: Redis的五种数据类型及使用场景 String 这个其实没啥好 ...

  8. Mybatis ResultMap复杂对象一对多查询结果映射之collection

    Mybatis复杂对象一对多映射配置ResultMap的collection collection:一对多查询结果映射,比如user有多个订单 表结构 项目结构图 pom.xml <?xml v ...

  9. Java-泛型,枚举,注解

    1 泛型类 package demo; public class FanXingLei { public static void main(String[] args) { // TODO 自动生成的 ...

  10. 🎉我是如何从零到成为 Apache 顶级项目的 Committer

    最近收到了 Apache Pulsar 和 Apache HertzBeat社区的邀请邮件,成为了这两个项目的 Committer. 一路走来我从最开始的打游击战的闲散人员到如今活跃在各个开源项目里的 ...