100% 2016-03-18 07:13 采纳率: 0%
浏览 1663

spring依赖注入测试时出错

错误如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'analysisService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.gbicc.dao.AnalysisMapper com.gbicc.service.AnalysisServiceImpl.analysisMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.gbicc.dao.AnalysisMapper] 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)}

我写的测试代码如下:
public class test {
@Test
public void maintest() {
ApplicationContext appContext = new ClassPathXmlApplicationContext("/spring.xml");
//ApplicationContext appContext = new AnnotationConfigApplicationContext("com.gbicc.service");
BlackListService bsi = appContext.getBean(BlackListService.class);

//BlackListServiceImpl bsi = new BlackListServiceImpl();
String bsmap = bsi.queryDictMap("dep01");
System.out.println(bsmap);
}
}
dao层和service层都是用注解实现的,现在的情况是从页面发送请求就没事,但是我直接用上面的测试代码就报错。

  • 写回答

1条回答

  • 夜半无声 2016-03-18 07:19
    关注

    analysisService和这个类的实现还有实现类中引用的类检查下标签是否多写了!

    评论

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?