java高并发Junit测试问题

java.lang.NoClassDefFoundError: Lorg/seckill/dao/SeckillDao;

at java.lang.Class.getDeclaredFields0(Native Method)

at java.lang.Class.privateGetDeclaredFields(Class.java:2317)

at java.lang.Class.getDeclaredFields(Class.java:1762)

at org.junit.runners.model.TestClass.<init>(TestClass.java:49)

at org.junit.runners.ParentRunner.<init>(ParentRunner.java:75)

at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:111)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)

at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)

at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)

at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)

at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)

at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)

at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:31)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(JUnit4TestMethodReference.java:25)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:54)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.lang.ClassNotFoundException: org.seckill.dao.SeckillDao

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

... 26 more

http://img.mukewang.com/584289710001e03f02750340.jpg

spring-dao.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"

        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-3.1.xsd">

<!-- 配置整合mybatis过程 -->

<!-- 1.配置数据库相关参数 -->

<!-- <bean id="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">


<property name="location">


<value>classpath:jdbc.properties</value>


</property>


<property name="fileEncoding" value="utf-8" />


</bean> -->

<context:property-placeholder location="classpath:jdbc.properties"/>

<!-- 2.配置连接池属性 -->

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooleDataSource">

<!-- 配置连接池属性 -->

<property name="driverClass" value="${driver}" />

<property name="jdbcUrl" value="${url}" />

<property name="username" value="${jdbc.username}" />

<property name="password" value="${password}" />

<!-- c3p0连接池私有属性 -->

<property name="maxPoolSize" value="30"/>

<property name="minPoolSize" value="10"/>

<!-- 关闭连接后不能自动commit -->

<property name="autoCommitOnClose" value="false"/>

<!-- 获取连接超时时间 -->

<property name="checkoutTimeout" value="1000"/>

<!--  获取连接失败重试次数-->

<property name="acquireRetryAttempts" value="2"/>

</bean>

<!-- 3.配置SqlSessionFactory -->

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<!-- 注入数据库连接池 -->

<property name="dataSource" ref="dataSource"/>

<!-- 配置mybatis全局配置文件 -->

<property name="configLocations" value="classpath:mybatis-config.xml"/>

<!-- 扫描sql配置文件 -->

<property name="mapperLocations" value="mapper/*.xml"/>

<!-- 扫描entity包 使用别名 -->

<property name="typeAliasesPackage" value="org.seckill.entity"/>

</bean>

<!-- 4.配置扫描Dao接口包,动态实现Dao接口,注入到Spring容器中 -->

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<!-- 注入sqlSessionFactory -->

<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>

<!-- 给出扫描Dao接口包 -->

<property name="basePackage" value="org.seckill.dao"/>

</bean>

</beans>


mjka5632
浏览 2318回答 2
2回答

永恒神话ch

楼主怎么解决的,我现在也遇到这个问题。。。。

Its_forever

没找到这个类SeckillDao。检查有没有这个类,有就重新编译一下。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java