Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Example Analysis of springboot2 Integrated oauth2

Shulou Source: shulou.com Published: 2022-06-02 02:40:56 11月15日 Update

Today, I will talk to you about the example analysis of springboot2 integration oauth2, many people may not know much about it. In order to make you understand better, the editor summarizes the following content for you. I hope you can get something according to this article.

@ EnableOAuth3Client annotation and customized the relevant configuration

@ 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 ();}

The following error will be reported after startup:

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:

There are two solutions: 1. Get rid of autoconfig dependence on spring-security-oauth3-autoconfigure 2 and use @ EnableAutoConfiguration to eliminate oauth3-related auto-assembly, which depends on the specific error message. As follows:

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

3. Add configuration spring.main.allow-bean-definition-overriding = true

After reading the above, do you have any further understanding of the example analysis of springboot2 integrated oauth2? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Content examples analysis configuration information solutions more notes knowledge articles industry information information channels errors channels will report enter one support related assembly Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Shulou Information macOS vpn