AreaServiceTest报错
来源:2-9 验证Sevice
慕斯卡4246828
2020-05-04
BaseTest中@ContextConfiguration({“classpath:spring/spring-dao.xml”})时AreaDaoTest可以通过,加上service的内容之后@ContextConfiguration({“classpath:spring/spring-dao.xml”, “classpath:spring/spring-service.xml”}),AreaDaoTest不能通过,AreaServiceTest也不能通过,报错
严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@783e6358] to prepare test instance [cn.supersy.o2o.service.AreaServiceTest@2925bf5b]
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'databaseType' threw exception; nested exception is java.lang.IllegalStateException: Driver for test database type [HSQL] is not available in the classpath
写回答
1回答
-
翔仔
2020-05-05
感觉是spring-service.xml配置错了?
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 扫描service包下所有使用注解的类型 --> <context:component-scan base-package="com.imooc.o2o.service" /> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!-- 注入数据库连接池 --> <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置基于注解的声明式事务 --> <tx:annotation-driven transaction-manager="transactionManager" /> </beans>
00
相似问题