求解一个在SSM里一个@Resource奇怪的问题
生如梦兮 2016-03-15 01:33:16 代码如下:
DAO文件:
public interface CustomInfoMapper {
List<CustomInfo> selectCustomInfoList(CustomInfo record);
}
Service文件:
@Service
@Transactional
public class CustomInfoService
{
@Resource(name="CustomInfoMapper")
private CustomInfoMapper customInfoMapper;
public List<CustomInfo> queryCustomInfoList(CustomInfo record)
{
return customInfoMapper.selectCustomInfoList(record);
}
}
问题在这,当我用@Resource(name="CustomInfoMapper"),资源带上显示命名时,就会报错Error creating bean with name 'customInfoService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'CustomInfoMapper' is defined,但是,我不用显示命名,只用@Resource的时候,一切又都正常运行,请问老司机,这个是个什么原因啊???谢啦!!