老师,2-7验证Dao时,Run testQueryArea时,提示如下错误
来源:2-5 配置Maven
慕圣7372446
2020-06-16
(我又重头检查了配置,和视频中的是一样的)
23:43:47.536 [main] DEBUG org.apache.ibatis.io.ResolverUtil - Checking to see if class com.imooc.o2o.entity.ShopCategory matches criteria [is assignable to Object]
23:43:47.537 [main] DEBUG org.apache.ibatis.io.ResolverUtil - Checking to see if class com.imooc.o2o.entity.WechatAuth matches criteria [is assignable to Object]
23:43:47.539 [main] DEBUG org.mybatis.spring.SqlSessionFactoryBean - Scanned package: ‘com.imooc.o2o.entity’ for aliases
六月 16, 2020 11:43:47 下午 org.springframework.context.support.GenericApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [spring/spring-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘com.imooc.o2o.dao.split.DynamicDataSourceInterceptor’. Cause: java.lang.ClassNotFoundException: Cannot find class: com.imooc.o2o.dao.split.DynamicDataSourceInterceptor
六月 16, 2020 11:43:47 下午 org.springframework.test.context.TestContextManager prepareTestInstance
严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@68837a77] to prepare test instance [com.imooc.o2o.dao.AreaDaoTest@156b88f5]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
1回答
-
慕圣7372446
提问者
2020-06-17
通过出错日志找到了,还是偷懒了,把mybatis-config.xml中的
<plugins>
<plugin interceptor="com.imooc.o2o.dao.split.DynamicDataSourceInterceptor">
</plugin>
</plugins>复制过来了,所以初始化时出错,屏蔽掉就OK了
10