相关疑难解决方法(0)

考虑在配置中定义类型为'org.springframework.security.authentication.AuthenticationManager'的bean

我遵循了这里提到的一些建议,但它对我不起作用.因此,在这里提出问题

  1. 如何在自定义筛选器中使用Java配置注入AuthenticationManager
  2. Spring需要一个'AuthenticationManager'类型的bean

谁能指导我是什么问题以及如何解决这个问题?

错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field authenticationManager in com.techprimers.security.springsecurityauthserver.config.AuthorizationServerConfig required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
Run Code Online (Sandbox Code Playgroud)

AuthorizationServerConfig.java

@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {

        security.tokenKeyAccess("permitAll()")
                .checkTokenAccess("isAuthenticated()");
    }


    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients
                .inMemory()
                .withClient("ClientId")
                .secret("secret")
                .authorizedGrantTypes("authorization_code")
                .scopes("user_info")
                .autoApprove(true);
    }


    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

spring spring-security spring-boot

12
推荐指数
3
解决办法
2万
查看次数

标签 统计

spring ×1

spring-boot ×1

spring-security ×1