zoukankan      html  css  js  c++  java
  • (转)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路径

  • 相关阅读:
    windows 下搭建安装 sass
    mac 下搭建安装 sass
    解决 document.getElementsByClassName 在 IE8 下的兼容下的问题
    placeholder颜色
    文本两端对齐
    css3之border-color
    pip 安装自己开发模块 边调试边修改
    Go语言格式化字符
    遍历修改django bootstrap form 为 django bootstrap3
    git 合并两个仓库
  • 原文地址:https://www.cnblogs.com/lzeffort/p/4570261.html
Copyright © 2011-2022 走看看