猿问

spring+mvc扫描注解一直报错?

org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

  •  

  •  

  •  




守候你守候我
浏览 819回答 1
1回答

慕码人8056858

你的service使用spring容器管理了吗,service使用@service指定bean名字,也可以默认。UserService 默认就是userService.你的注解扫描包 包含了你的bean定义吗。Web层注入@Autowired@Qualifier("userService")private UserService userService;
随时随地看视频慕课网APP
我要回答