Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 春季安全问题_Spring_Dependency Injection_Spring Security - Fatal编程技术网

Spring 春季安全问题

Spring 春季安全问题,spring,dependency-injection,spring-security,Spring,Dependency Injection,Spring Security,我正在尝试使用注释启用spring安全性,并对其进行测试。我已将以下内容放入上下文文件: <context:component-scan base-package="com.example.service" /> <security:global-method-security secured-annotations="enabled" /> 但是,当我放置安全注释以启用上下文:组件扫描时,不会创建留在包中的服务…为什么会发生这种情况 这是主要原因: Caused by:

我正在尝试使用注释启用spring安全性,并对其进行测试。我已将以下内容放入上下文文件:

<context:component-scan base-package="com.example.service" /> <security:global-method-security secured-annotations="enabled" /> 但是,当我放置安全注释以启用上下文:组件扫描时,不会创建留在包中的服务…为什么会发生这种情况

这是主要原因:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.example.service.ServiceImpl com.example.service.ServiceImplTest.service; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.example.service.ServiceImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283) ... 32 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.example.service.ServiceImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478) ... 34 more 原因:org.springframework.beans.factory.BeanCreationException:无法自动连线字段:com.example.service.serviceinpl com.example.service.serviceinmpltest.service;嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到依赖项类型为[com.example.service.ServiceImpl]的匹配bean:至少需要1个符合此依赖项autowire候选项条件的bean。依赖项注释:{@org.springframework.beans.factory.annotation.Autowired(required=true)} 位于org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement.inject(AutoWiredNotationBeanPostProcessor.java:507) 位于org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) 位于org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor.postProcessPropertyValues(AutoWiredNotationBeanPostProcessor.java:283) ... 32多 原因:org.springframework.beans.factory.NoSuchBeanDefinitionException:未找到依赖项类型为[com.example.service.ServiceImpl]的匹配bean:至少需要1个符合此依赖项autowire候选项条件的bean。依赖项注释:{@org.springframework.beans.factory.annotation.Autowired(required=true)} 位于org.springframework.beans.factory.support.DefaultListableBeanFactory.RaiseNouchBeanDefinitionException(DefaultListableBeanFactory.java:920) 位于org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) 位于org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) 位于org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement.inject(AutoWiredNotationBeanPostProcessor.java:478) ... 34多
spring有任何输出吗?当我启用它时,我在一个bean中有一个异常原因被注入到我的服务中,但在上下文中找不到它…我看到,如果启用了安全注释…则不会创建带有注释的类…而如果我删除注释,它会工作(但没有安全性)请发布完整的异常跟踪-如果您想获得帮助,您应该提供任何相关信息安全注释放在哪里(在哪个类),这真的是strack跟踪的结束吗?也许你也应该发布你使用的安全注释。