springboot2集成oauth2坑二(The bean 'scopedTarget.oauth2ClientContext', defined in class path resource )
码云地址: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 )的更多相关文章
- Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
项目是集成了Spring Boot和Spring Data,然后昨天简单Jpa和Spring Boot配置完成,开始进行公司项目的重构,然后出现了这个问题.当时是在网上找了好久.后来发现时java ...
- 【报错】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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource
我们在SpringBoot中用Jedis来访问Redis,其中Redis是采用集群(单机没有本篇文章的问题)的方式,在启用Redis的时候碰到如上问题. 错误的核心信息如下: Error creati ...
- 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 ...
- 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' ...
- 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 ...
随机推荐
- linux下后台运行程序
文章目录 背景 nohup命令 setsid命令 pm2 背景 后台运行程序的时候,如果退出当前的终端(session),你运行的所有程序(包括后台程序),都将被关闭. 原因是:你运行的程序都是你的终 ...
- Nuxt3 的生命周期和钩子函数(一)
title: Nuxt3 的生命周期和钩子函数(一) date: 2024/6/25 updated: 2024/6/25 author: cmdragon excerpt: 摘要:本文是关于Nuxt ...
- Android日志系统(logging system)
Android日志系统(logging system) 背景 不管是做Android应用还是做Android中间层和底层,在做一些调试工作的时候,使用adb logcat非常关键.特意学习了一下安卓的 ...
- Markdown 文章 跳转
背景 在查阅一些文档的时候,一些比较优秀博客在文章中是带有目录的,点击就会跳转到指定的锚点. 在本人的某些文章中,也想尝试这样的效果. 做法 实现这样的效果有2种做法(不同之处在于 超链接的写法不同) ...
- Redis的几种应用实战
1.分布式锁: 实现:用set key value ex time nx指令实现,这个指令以及其参数是原子性的操作.释放锁用del key,释放之前先比较一下value是否与当前的value一样,原因 ...
- 【深度学习 有效炼丹】多GPU使用教程, DP与DDP对比, ray多线程并行处理等 [GPU利用率低的分析]
️ 前言 更新日志: 20220404:新增一个DDP 加载模型时显存分布不均问题,见目录遇到的问题及解决处 主要是上次server12 被自己一个train 直接线程全部拉满了(没错 ... ser ...
- 【Ubuntu 1】ubuntu的软件包及便携系列 记录
目录 命令行补充[备注记录] 不想每次---- source /devel/setup.bash sudo chomd 777 /dev/ttyUSB* 安装区 --- 强推!Synergy Chro ...
- 从PDF到OFD,国产化浪潮下多种文档格式导出的完美解决方案
前言 近年来,中国在信息技术领域持续追求自主创新和供应链安全,伴随信创上升为国家战略,一些行业也开始明确要求文件导出的格式必须为 OFD 格式.OFD 格式目前在政府.金融.税务.教育.医疗等需要文件 ...
- 全网最适合入门的面向对象编程教程:07 类和对象的Python实现-类型注解-提高代码可读性的利器
全网最适合入门的面向对象编程教程:07 类和对象的 Python 实现-类型注解-提高代码可读性的利器 摘要: 本文对类型注解的定义.使用原因进行了基本介绍,同时对使用 typing 模块实现类型提示 ...
- 分享一个国内可用的ChatGPT网站,免费无限制,支持AI绘画
背景 ChatGPT作为一种基于人工智能技术的自然语言处理工具,近期的热度直接沸腾. 作为一个AI爱好者,翻遍了各大基于ChatGPT的网站,终于找到一个免费!免登陆!手机电脑通用!国内可直接对话的C ...