坑爹的Spring

18:04:21,581 [main] INFO JedisPoolFactory.java:111 - init jedis pools, size:7
18:04:24,798 [main] ERROR RoseFilter.java:307 - [[email protected]]:Error creating bean with name 'ModuleBuilder.com.jingwei.aut.controllers.LoginController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.jingwei.aut.service.PermissionService com.jingwei.aut.controllers.LoginController.pService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.jingwei.aut.service.PermissionService] 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)}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ModuleBuilder.com.jingwei.aut.controllers.LoginController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.jingwei.aut.service.PermissionService com.jingwei.aut.controllers.LoginController.pService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.jingwei.aut.service.PermissionService] 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.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)


没有实现类!!!!
@Component实现类的头上没有注解!!!!


例子2:
 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.jingwei.card.passport.home.MainAccountHome] is defined: expected single bean but found 2

问题原因:
在core包中:
<context:component-scan name-generator="com.jingwei.core.spring.BeanNameGenerator" base-package="com.jingwei.card.passport.component"></context:component-scan>
	<context:component-scan name-generator="com.jingwei.core.spring.BeanNameGenerator" base-package="com.jingwei.card.passport.home"></context:component-scan>

而在web工程中
<context:component-scan base-package="com.jingwei" />

结论:
这个类被扫了两遍,所以在getInstant的时候,会找到两个

解决:
web工程或者其他工程中,应该尽量扫描自己的目录
<context:component-scan base-package="com.jingwei.cardverify" />

你可能感兴趣的:(spring)