当前位置: 首页 > 知识库问答 >
问题:

NoSuchBeanDefinitionException,但bean被定义

范鸿
2023-03-14

我正在尝试使用基于Java的配置而不是来自这篇博文的XML配置将配置引入Spring Boot:http://blog.novoj.net/2012/03/27/combining-custom-annotations-for-securing-methods-with-spring-security/

我得到以下例外:

org . spring framework . beans . factory . unsatisfieddependencyexception:创建在类路径资源[test/project/security/AOP/aopsecurityconfiguration . class]中定义的名为“postAuthorizeAdvisor”的bean时出错:通过索引为0的类型为[org . spring framework . security . access . intercept . aopalliance . methodsecurityinterceptor]的构造函数参数表示的未满足的依赖关系:未找到类型为[org . spring framework . security . access . intercept . aopalliance . methodsecurityinterceptor]的合格bean依赖项批注:{ };嵌套异常为org . spring framework . beans . factory . nosuchbeandetification异常:找不到类型为[org . spring framework . security . access . intercept . aopalliance . methodsecurityinterceptor]的合格bean用于依赖项:至少需要1个bean作为此依赖项的自动连线候选项。依赖项注释:{}

以下是包含这些bean定义的类:

@Configuration
public class AopSecurityConfiguration {
    @Bean
    public MethodSecurityInterceptor methodSecurityInterceptor(AuthenticationManager authenticationManager) {
        MethodSecurityInterceptor msi = new MethodSecurityInterceptor();
        msi.setAuthenticationManager(authenticationManager);
        msi.setValidateConfigAttributes(false);

        MethodSecurityExpressionHandler handler = new DefaultMethodSecurityExpressionHandler();

        ExpressionBasedAnnotationAttributeFactory factory = new ExpressionBasedAnnotationAttributeFactory(handler);
        ExperimentalPrePostAnnotationSecurityMetadataSource metadataSource = new ExperimentalPrePostAnnotationSecurityMetadataSource(factory);
        msi.setSecurityMetadataSource(metadataSource);

        ExpressionBasedPreInvocationAdvice advice = new ExpressionBasedPreInvocationAdvice();
        advice.setExpressionHandler(handler);
        AccessDecisionVoter<?> voter = new PreInvocationAuthorizationAdviceVoter(advice);
        AccessDecisionManager manager = new AffirmativeBased(Collections.singletonList(voter));
        msi.setAccessDecisionManager(manager);

        return msi;
    }

    @Bean
    public Advisor preAuthorizeAdvisor(MethodSecurityInterceptor methodSecurityInterceptor) {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("execution(@(@org.springframework.security.access.prepost.PreAuthorize *) * *.* (..))");
        return new DefaultPointcutAdvisor(pointcut, methodSecurityInterceptor);
    }

    @Bean
    public Advisor preFilterAdvisor(MethodSecurityInterceptor methodSecurityInterceptor) {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("execution(@(@org.springframework.security.access.prepost.PreFilter *) * *.* (..))");
        return new DefaultPointcutAdvisor(pointcut, methodSecurityInterceptor);
    }

    @Bean
    public Advisor postAuthorizeAdvisor(MethodSecurityInterceptor methodSecurityInterceptor) {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("execution(@(@org.springframework.security.access.prepost.PostAuthorize *) * *.* (..))");
        return new DefaultPointcutAdvisor(pointcut, methodSecurityInterceptor);
    }

    @Bean
    public Advisor postFilterAdvisor(MethodSecurityInterceptor methodSecurityInterceptor) {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("execution(@(@org.springframework.security.access.prepost.PostFilter *) * *.* (..))");
        return new DefaultPointcutAdvisor(pointcut, methodSecurityInterceptor);
    }
}

找不到 MethodSecurityInterceptor bean 的原因是什么?

编辑

这是完整的堆栈跟踪:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedServletContainerCustomizerBeanPostProcessor': BeanPostProcessor before instantiation of bean failed; nes
ted exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aopSecurityConfiguration' defined in file [C:\test\test-project\build\classes\main\test\project
\security\aop\AopSecurityConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'postF
ilterAdvisor' defined in class path resource [test/project/security/aop/AopSecurityConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springf
ramework.security.access.intercept.aopalliance.MethodSecurityInterceptor]: : No qualifying bean of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor] found for 
dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionEx
ception: No qualifying bean of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor] found for dependency: expected at least 1 bean which qualifies as autowire can
didate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:472)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:232)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at test.project.Application.main(Application.java:15)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aopSecurityConfiguration' defined in file [C:\test\test-project\build\classes\main\test\project\secur
ity\aop\AopSecurityConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'postFilterA
dvisor' defined in class path resource [test/project/security/aop/AopSecurityConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframewo
rk.security.access.intercept.aopalliance.MethodSecurityInterceptor]: : No qualifying bean of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor] found for depend
ency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionExceptio
n: No qualifying bean of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor] found for dependency: expected at least 1 bean which qualifies as autowire candidate
 for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:101)
    at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:85)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:243)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:984)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:955)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:466)
    ... 13 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'postFilterAdvisor' defined in class path resource [test/project/security/aop/AopSecurityConf
iguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor]: : No qualify
ing bean of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dep
endency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.access.intercept.aopa
lliance.MethodSecurityInterceptor] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:101)
    at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:85)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:324)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.getEarlyBeanReference(AbstractAutoProxyCreator.java:232)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getEarlyBeanReference(AbstractAutowireCapableBeanFactory.java:819)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$2.getObject(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:192)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:173)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:240)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:101)
    at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:85)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:324)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.getEarlyBeanReference(AbstractAutoProxyCreator.java:232)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getEarlyBeanReference(AbstractAutowireCapableBeanFactory.java:819)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$2.getObject(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:192)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:173)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:240)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:101)
    at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:85)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:324)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    ... 35 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor] found for d
ependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 95 common frames omitted

编辑

我能够通过删除我的WebSecurityCon的实现来解决这个问题。这删除了我对身份验证管理器和HttpSecurity的配置。

对于身份验证管理器,我的理解是,我需要创建一个身份验证提供程序来处理用户的身份验证,所以我使用了Dao身份验证提供程序和InMemoryUserDemailsManager来创建一个简单的提供程序。这是以前使用身份验证管理器#inMemoryAuth

我不确定我需要如何设置HttpSecurity的一个实例,以便我可以使用表单登录,我可以用WebSecurityConfigurerAdapter来完成。

共有2个答案

元嘉木
2023-03-14

我已经找到了如何纠正这一点,不完全确定为什么会这样,但它确实如此。我删除了 AopSecurityConfiguration 类,并将 methodSecurityInterceptor 方法移动到我的 WebSecurityConfigurerAdapter 实现中,并删除了 authenticationManager 参数。在方法中,我现在调用 WebSecurityConfigurerAdapter 的 authenticationManager 方法。

这样做允许我创建自定义的Pre/PostAuthorize注释注释,我可以使用RulesRelation注释和/或注释。

不确定最初博客上描述的切入点顾问需要做什么,也许这是以前版本需要的,但现在不再需要了?

杜起运
2023-03-14

您必须在使用methodSecurityInterceptor的每个方法的顶部添加@Autowiredannotation。

例如:

@Bean
@Autowired
public Advisor postAuthorizeAdvisor(MethodSecurityInterceptor methodSecurityInterceptor) {
    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression("execution(@(@org.springframework.security.access.prepost.PostAuthorize *) * *.* (..))");
    return new DefaultPointcutAdvisor(pointcut, methodSecurityInterceptor);
}
 类似资料:
  • 我之前在我的项目中使用了XML配置,一切都正常工作。 我们正在逐步转向java配置,所以现在我正处于一个混合使用java和XML配置的阶段。 我得到以下错误: UnsatisfiedDependencyException:创建名为“bean B”的bean时出错:通过字段“bean A”表示未满足的依赖关系; 嵌套异常是org.springframework.beans.factory.nosuc

  • 我对Spring框架非常陌生。我正在使用NetBeans作为IDE。我跟着几个教程自学。然而,我陷入了中间,不能继续前进。让我在这里分解一下我的项目: 我的项目文件夹结构如下: 有两个班;主要的一个主应用程序。java包含以下代码: 第二类文件第一页。java看起来像这样: 豆子。xml文件如下所示: 现在,我得到的错误如下: 组织。springframework。豆。工厂NoSuchBeanDe

  • 我正在尝试一个非常基本的例子。我试图查看其他堆栈溢出答案,但无法解决此问题。我是新来的这个空间,让我知道如果我遗漏了什么。 这是我的错误日志: 2017年12月11日上午8:40:20org.springframework.beans.factory.xml.XmlBean定义Reader loadBean定义信息:从类路径资源[BeanDefinition.xml]加载XML bean定义]线程

  • 我有一个简单的spring 4 WebMVC应用程序(-config),我想添加JPA。但是,当我尝试运行应用程序时(就像在Tomcat上的deloyed一样),我会发现:什么可能是错误的来源? 创建名为“index controller”的bean时出错:注入autowired依赖项失败;嵌套异常为org.springframework.beans.factory.beancreationexc

  • 我有一个Spring服务正在检查数据库条目。为了最小化我的存储库调用,两个find方法都是“@cacheable”。但是,当我尝试初始化我的服务bean,而我的配置类有一个CacheManager bean定义时,我会得到以下NosuchBeanDefinitionException: 如果我取出CacheManager bean定义,我可以初始化我的服务bean,它运行时没有任何问题和缓存! 下