错误代码(贴的前部分):
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.taotao.manage.service.ItemDescService com.taotao.manage.service.ItemService.itemDescService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.taotao.manage.service.ItemDescService] 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)}
错误原因:
再service上@Service注解忘记添加了,导致bean找不到ItemDescService。
SSM书写步骤大致如下:
contorller
@RequestMapping(value="item")
@Controller
public class ItemContorller {
@Autowired
private ItemService itemService;
}
service
@Service
public class ItemService extends BaseService<Item>{
@Autowired
private ItemMapper itemMapper;
}
mapper,继承pojo
public interface ItemMapper extends Mapper<Item> {
}