Recently, I was maintaining an old project. As a result, I modified a jar package. After the package is repackaged, the following error occurs when the project is started:
32417 [main] 13 Aug 2012 10:46:21, 318 ERROR org. springframework. web. context. ContextLoader initWebApplicationContext-Context initialization failed
Org. springframework. beans. factory. beanCreationException: Error creating bean with name 'userservice': Autowiring of fields failed; nested exception is org. springframework. beans. factory. beanCreationException: cocould not autowire field: private com. oss. service. userService com. oss. ws. server. impl. userServiceImpl. userService; nested exception is org. springframework. beans. factory. noSuchBeanDefinitionException: No unique bean of type [com. oss. service. userService] is defined: Unsatisfied dependency of type [class com. oss. service. userService]: expected at least 1 matching bean
... More
Caused by: org. springframework. beans. factory. beanCreationException: cocould not autowire field: private com. oss. service. userService com. gnet. tang. usermanager. ws. server. impl. userServiceImpl. userService; nested exception is org. springframework. beans. factory. noSuchBeanDefinitionException: No unique bean of type [com. oss. service. userService] is defined: Unsatisfied dependency of type [class com. oss. service. userService]: expected at least 1 matching bean
... 40 more
Caused by: org. springframework. beans. factory. noSuchBeanDefinitionException: No unique bean of type [com. oss. service. userService] is defined: Unsatisfied dependency of type [class com. oss. service. userService]: expected at least 1 matching bean
... 42 more
Through analysis, we found that userService is annotated by @ service in spring, and then searched for these classes in xml and initialized beans through context: component-scan. After the experiment, it is found that the new class is put into the old jar by using the rar tool, which indicates that the packaging process is wrong.
You can solve this problem by selecting the "Add directory entries" option during packaging. For example:
Author: jkeven