• (转)myeclipse工程 junit不能运行 ClassNotFoundException


    博文转自:http://www.cnblogs.com/java-zone/articles/2730722.html

    myeclipse工程   junit不能运行

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    java.lang.ClassNotFoundException: com.huawei.adapter.XXXXXTest
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
        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)

     

    原因在于maven生成class的目录被改变,需要重新设置output目录,

    解决办法一:

    打开工程的.classpath文件:

    1
    2
    3
    4
    5
    6
    7
    <?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"加上就好用了

      

    1
    2
    3
    4
    5
    <?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"/>

      

     解决办法二:

      1.打开项目,右击进入Properties>>JAva Build Path    

      2.勾选下方Allow  output folders for source folders

      3.设置上方的output folder路径

  • 相关阅读:
    蓝桥杯历届试题 打印十字图 文字图形
    Cuckoo Hashing
    2006 飞行员配对(二分图最大匹配)
    Bad Hair Day(求数组中元素和它后面离它最近元素之间的元素个数)
    2019CCPC江西省赛
    字典树系统学习
    ac自动机学习
    项目管理(把与某点相邻边分为两类 是复杂度降为(n^(3/2))
    Ultra-QuickSort(离散化)
    Chika and Friendly Pairs(莫队+树状数组+离散化+预处理上下界)
  • 原文地址:https://www.cnblogs.com/lzeffort/p/4570261.html
Copyright © 2020-2023  润新知