问答详情
源自:4-8 DAO层单元测试编码和问题排查(上)

求大神解答 java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactory

说明:Maven Dependencies 已包含 mybatis-spring-1.2.3.jar


Caused by: java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactory

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

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

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

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

at org.springframework.util.ClassUtils.forName(ClassUtils.java:249)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1349)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1320)



提问者:大宝他爹 2016-06-10 12:01

个回答

  • _白驹过隙_
    2017-02-18 22:29:39

    打开工程的.classpath文件:

    <?xml version="1.0" encoding="UTF-8"?>

    <classpath>

        <classpathentry kind="src" path="src/main/java"/>

        <classpathentry kind="src" path="src/main/config"/>

        <classpathentry kind="src"  path="src/test/java"/>

                    .......

    </classpath

       


      

    将output="target/test-classes"加上就好用了


       

    <?xml version="1.0" encoding="UTF-8"?>

    <classpath>

        <classpathentry kind="src" path="src/main/java"/>

        <classpathentry kind="src" path="src/main/config"/>

        <classpathentry kind="src"  output="target/test-classes" path="src/test/java"/>

       


  • 大宝他爹
    2016-06-10 12:26:18

    已解决,maven clean 之后重新 build 就可以了