Class not found com.imooc.o2o.AreaDaoTest
来源:2-7 验证Dao
慕勒0488589
2019-03-29
报错:Class not found com.imooc.o2o.AreaDaoTest
看了一些问答 感觉可能是spring-dao.xml文件有问题但对比了一下也找不出问题 希望老师能解答一下 这是我的 xml文件
<?xml version="1.0" encoding="UTF-8"?>
classpath:jdbc.properties
classpath:redis.properties
<!-- 3.配置SqlSessionFactory对象 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource" />
<!-- 配置MyBaties全局配置文件:mybatis-config.xml -->
<property name="configLocation" value="classpath:mybatis-config.xml" />
<!-- 扫描entity包 使用别名 -->
<property name="typeAliasesPackage" value="com.imooc.entity" />
<!-- 扫描sql配置文件:mapper需要的xml文件 -->
<property name="mapperLocations" value="classpath:mapper/*.xml" />
</bean>
<!-- 4.配置扫描Dao接口包,动态实现Dao接口,注入到spring容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 注入sqlSessionFactory -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
<!-- 给出需要扫描Dao接口包 -->
<property name="basePackage" value="com.imooc.o2o.dao" />
</bean>
写回答
2回答
-
慕勒0488589
提问者
2019-04-02
Class not found com.imooc.o2o.dao.AreaDaoTest java.lang.ClassNotFoundException: com.imooc.o2o.dao.AreaDaoTest at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:770) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:499) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
00 -
翔仔
2019-03-30
同学好,这里说的是Class not found com.imooc.o2o.AreaDaoTest
找不到测试类,暂时跟dao无关呢。
需要同学看看AreaDaoTest这个类有没有继承BaseTest.java
BaseTest.java里是否是这样的
package com.imooc.o2o; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * * 配置spring和junit整合,junit启动时加载springIOC容器 * */ @RunWith(SpringJUnit4ClassRunner.class) // 告诉junit spring配置文件的位置 @ContextConfiguration({ "classpath:spring/spring-dao.xml", "classpath:spring/spring-service.xml", "classpath:spring/spring-redis.xml" }) public class BaseTest { }
如果是idea的话还有可能跟下面的链接有关
https://www.jianshu.com/p/b869f2986b58
052019-04-03
相似问题