SSM Service automatically inject a failure

Error First posted:

Error creating bean with name 'testController': 
Unsatisfied dependency expressed through field 'userInfoService': No qualifying bean of type [bcs.wms.service.UserInfoService] found for dependency [bcs.wms.service.UserInfoService]:
expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)};
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [bcs.wms.service.UserInfoService] found for dependency [bcs.wms.service.UserInfoService]:
expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Service Times automatically injected more errors in the controller.

1, we must first ensure that the syntax is correct (including added @Service comment)

2. Second is to see there is no configuration profile associated with automatic scanning, and more than likely to be in a file you want to configure.

spring configuration file to configure, spring-mvc configuration file should be configured. It is precisely because of this error is not configured in a spring-mvc configuration file, which leads to errors when the controller layer automatically inject Service.

solution:

In the spring, springmvc configuration file, should be added:

   <Context: component-scan base-package = "bcs.wms.service" /> (bcs.wms.service replace their packages)

Guess you like

Origin www.cnblogs.com/phdeblog/p/12149091.html