java - 无法注册 Bean 'scopedTarget.oauth2ClientContext' 相同的 bean 名称已在类路径中定义
问题描述
我很简单地尝试为我的应用启用谷歌登录功能,但遇到了这个特定的错误。我不明白这个问题为什么我得到它?我需要帮助来解决此错误吗?有什么提示吗?
@Configuration
@EnableOAuth2Sso
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/welcomepage")
.permitAll()
.anyRequest()
.authenticated();
}
}
***************************
APPLICATION FAILED TO START
***************************
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:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
解决方案
我遇到了同样的问题。我通过将 spring-security-oauth2-autoconfigure 库的版本升级到 2.1.1.RELEASE 来解决它。
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
推荐阅读
- actions-on-google - 为 NodeJS 初始化 Google Actions SDK 后更新 clientId
- php - 如何使用 bootstrap 4 modal 创建日期过滤器过滤器
- c# - 是否有一个测试数据构建器可以处理没有默认构造函数的类?
- r - 将函数应用于小标题的每个案例
- mongodb - MongoDB聚合查询优化:match -> unwind -> match vs unwind->match
- vb.net - mciSendString,将 VB 脚本移植到 CE Lua 脚本
- git - 如何为合并和冲突解决提供不同的提交
- azure - 通过 Azure Blob 存储对静态 Web 托管终结点进行 IP 筛选
- java - 无法在 Android 中的频道 null 上发布通知
- java - 使用 XML 数据时出错内容类型 'application/xml;charset=utf-8' 不支持 spring