【问题标题】:No matching bean of type [org.springframework.security.oauth2.provider.code.ClientAuthenticationCache没有匹配的类型 [org.springframework.security.oauth2.provider.code.ClientAuthenticationCache
【发布时间】:2011-12-07 13:52:18
【问题描述】:

嗨,我在 Spring Security 应用程序中遇到了以下错误,我无法上传限制大上传的公司详细信息, 有什么问题?

org.springframework.beans.factory.BeanCreationException:创建名为“accessConfirmationController”的bean时出错:我 自动装配依赖项的注入失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配方法:public void o rg.springframework.security.oauth.examples.sparklr.mvc.AccessConfirmationController.setAuthenticationCache(org.springframework.security.oauth2.provider.code.Cli entAuthenticationCache);嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.secu rity.oauth2.provider.code.ClientAuthenticationCache] 找到依赖项:预计至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。 D 依赖注释:{}: org.springframework.beans.factory.NoSuchBeanDefinitionException:没有匹配的 bean 类型 [org.springframework.security.oauth2.provider.code.ClientAuthenticatio nCache] 找到依赖项:预计至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。依赖注解

【问题讨论】:

    标签: hibernate spring spring-security


    【解决方案1】:

    从您的日志中,您应该有一个名为 AccessConfirmationController 的类。它有一个类型为 ClientAuthenticationCache 的内部属性,对吧?

    错误表明您没有定义任何类型为 ClientAuthenticationCache 的 bean,因此也无法创建 AccessConfirmationController bean。

    您可以使用 Spring 的 component scanning feature 自动检测和实例化 ClientAuthenticationCache 。

    要启用组件扫描功能,请在applicationContext.xml 中添加<context:component-scan base-package="some.package">。指定base-package 中的任何类及其使用@Component 子类型注释的子包,例如@Controller、@Repository、@Service可以被Spring自动发现和实例化。

    【讨论】:

    • 我删除了ClientAuthenticationCache上面的Autowire,我实例化了,它解决了
    【解决方案2】:

    这意味着您正在尝试注入(可能是通过@Autowired 注释?)org.springframework.secu rity.oauth2.provider.code.ClientAuthenticationCache 类型的 bean,但您的应用程序中没有定义这样的 bean。

    【讨论】:

    • 我如何定义 ClientAuthenticationCache 我不知道,有没有办法定义使用自动连接
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 2020-10-30
    • 2022-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多