小编Zoh*_*han的帖子

无法在Spring Boot 2.0.0中自动装配身份验证管理器

所以我一直在尝试在一个简单的Spring MVC应用程序中实现oAuth2.

在我关注的指南中,AuthorizationServerConfigurerAdapter他们@Autowired是一个AuthenticationManager.他们使用Spring Boot 1.5.2版.

我想使用Spring Boot 2.0.0,因为这是最新版本,所以我想学习最新的实践.但是,当我改变时,在我的pom.xml中:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)

至:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)

突然间,我无法自动装配AuthenticationManager.

Could not autowire. No beans of 'AuthenticationManager' type found.

有人可以提出解决方案吗?

谢谢!

java spring-mvc spring-security oauth-2.0 spring-boot

4
推荐指数
2
解决办法
4858
查看次数

无法在 spring 中处理配置类的导入候选

我试图运行我的 Spring MVC 应用程序,但由于某种原因GlobalAuthenticationConfigurerAdapter无法找到。

下面是代码片段:

package co.uk.zohaibkhan.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;


@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {

  @Override
  public void configure(AuthorizationServerSecurityConfigurer oauthServer) {
    oauthServer.checkTokenAccess("isAuthenticated()");
  }

  @Override
  public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
    clients.inMemory().withClient("my-trusted-client")
        .authorizedGrantTypes("client_credentials", "password")
        .authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
        .scopes("read", "write", "trust")
        .resourceIds("oauth2-resource")
        .accessTokenValiditySeconds(5000)
        .secret("secret");
  }


  @Override
  public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    super.configure(endpoints);
  }
}
Run Code Online (Sandbox Code Playgroud)

和堆栈跟踪:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [co.uk.zohaibkhan.config.AuthorizationServerConfig]; nested …
Run Code Online (Sandbox Code Playgroud)

java rest spring maven spring-security-oauth2

1
推荐指数
1
解决办法
7813
查看次数