idea上使用maven分模块开发时解决spring注入失败问题java.lang.IllegalStateException: Failed to load ApplicationContext
2017-12-27 23:44
1016 查看
使用maven分模块开发时,将项目分成三次dao(bean),service,web,其中dao层包含了bean和applicationContext,hibernate配置文件,service层依赖dao,也包含了spring配置文件(spring管理三层,所以都需要spring配置文件)。
首先配置号dao层,install发布到本地仓库,此时dao是jar格式,service引入dao.jar依赖解决依赖关系,但是service层配置spring文件时,无法找到spring容器内的dao对象,配置报错
此时只需导入dao层的配置文件即可
首先配置号dao层,install发布到本地仓库,此时dao是jar格式,service引入dao.jar依赖解决依赖关系,但是service层配置spring文件时,无法找到spring容器内的dao对象,配置报错
<bean id="customerService" class="service.Impl.CustomerServiceImpl"> <property name="customerDao" ref="customerDao"></property> </bean>
此时只需导入dao层的配置文件即可
<import resource="applicationContext_dao.xml"></import>
<bean id="customerService" class="service.Impl.CustomerServiceImpl"> <property name="customerDao" ref="customerDao"></property> </bean>
相关文章推荐
- SSH如何使用junit4进行单元测试,java.lang.IllegalStateException: Failed to load ApplicationContext 问题
- 解决java.lang.IllegalStateException: Failed to load ApplicationContext 问题
- maven+spring测试出现 java.lang.IllegalStateException: Failed to load ApplicationContext异常
- 求助!精通Spring 4.x 企业应用开发实战;第二章;测试过程报java.lang.IllegalStateException: Failed to load ApplicationContext
- java.lang.IllegalStateException: Failed to load ApplicationContext解决办法
- java.lang.IllegalStateException: Failed to load ApplicationContext解决办法
- junit测试spring整合activeMQ报错:java.lang.IllegalStateException: Failed to load ApplicationContext
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...今天
- Spring3.x 版本和 JDK1.8 不兼容导致 java.lang.IllegalStateException: Failed to load ApplicationContext
- java spring java.lang.IllegalStateException: Failed to load ApplicationContext异常
- spring 3.2 错误java.lang.IllegalStateException: Failed to load ApplicationContext
- Junit4测试错误解决java.lang.IllegalStateException: Failed to load ApplicationContext
- spring 配置文件无法加载,junit找不到xml配置文件java.lang.IllegalStateException: Failed to load ApplicationContext
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...
- java.lang.IllegalStateException: Failed to load ApplicationContext的原因和解决办法
- SSH基于注解的junit测试:java.lang.IllegalStateException: Failed to load ApplicationContext问题
- java.lang.IllegalStateException: Failed to load ApplicationContext异常解决方法
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...
- Spring错误:java.lang.IllegalStateException: Failed to load ApplicationContext
- java.lang.IllegalStateException: Failed to load ApplicationContext