SpringBoot2.x集成springSecurity和OAuth2.0啟動錯誤處理


當啟用@EnableAuthorizationServer注解時,啟動項目報錯

報錯信息

Description:


Field configurers in org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerSecurityConfiguration required a bean of type 'java.util.List' that could not be found.


The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Value(value=#{@autowiredWebSecurityConfigurersIgnoreParents.getWebSecurityConfigurers()})

Action:

Consider defining a bean of type 'java.util.List' in your configuration.


Process finished with exit code 1

 

因為SpringBoot2.x已經將 security.oauth2的自動配置類spring-boot-autoconfigure的jar中移除。

如OauthAuthorizationServerConfiguration.java配置類在spring-boot-autoconfigure-1.3.5.RELEASE.jar中還是存在的
解決方法
添加maven依賴
<dependency>
    <groupId>org.springframework.security.oauth.boot</groupId>
    <artifactId>spring-security-oauth2-autoconfigure</artifactId>
    <version>2.0.0.RELEASE</version>
</dependency>

 

SpringBoot2.x集成springSecurity,OAuth2.0的完整maven依賴

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
    <version>2.2.3.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security.oauth</groupId>
    <artifactId>spring-security-oauth2</artifactId>
    <version>2.2.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security.oauth.boot</groupId>
    <artifactId>spring-security-oauth2-autoconfigure</artifactId>
    <version>2.0.0.RELEASE</version>
</dependency>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM