spring是不是少了什么啊,总是抛异常,autowired自动装配有问题
spring.xml:
<bean id="itemsService" class="ssm.check.service.impl.ItemsServiceImpl" >
</bean>
</beans>
controller的定义:[code=java]
@Controller
public class ItemsController {
@Autowired
private ItemsService itemsService;
@RequestMapping("/findItemsByName")
public ModelAndView findItemsByName() {
// 商品列表
List<ItemsCustom> itemsList = itemsService.findItemsByName(null);
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("itemsList", itemsList);
// 视图
modelAndView.setViewName("WEB-INF/jsp/items/itemsList.jsp");
return modelAndView;
}
}
异常:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ssm.check.mapper.ItemsCustomMapper ssm.check.service.impl.ItemsServiceImpl.itemsCustomMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [ssm.check.mapper.ItemsCustomMapper] 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)}