java gwt 测试:无法在您的类路径中找到 sample.gwt.xml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4550483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 06:54:34  来源:igfitidea点击:

gwt test: unable to find sample.gwt.xml on your classpath

javagwtclasspath

提问by user468587

I'm running gwt test for my application, it's like a nightmare, got problem one after another, not sure what's going wrong.

我正在为我的应用程序运行 gwt 测试,这就像一场噩梦,一个接一个地出现问题,不知道出了什么问题。

First, I created a dummy test case:

首先,我创建了一个虚拟测试用例:

public class ListItemTest extends GWTTestCase {

  /**
   * Specifies a module to use when running this test case. The returned
   * module must include the source for this class.
   * 
   * @see com.google.gwt.junit.client.GWTTestCase#getModuleName()
   */
    @Override
    public String getModuleName() {
        return "com.dyihi.services.sample.Sample";
    }

    /**
     * Add as many tests as you like
     */
    public void testSimple() {
        assertTrue(true);
    }
}

When I ran 'mvn test' this simple test failed. The error message is:

当我运行“mvn test”时,这个简单的测试失败了。错误信息是:

initializationError0
java.lang.NoClassDefFoundError: com/google/gwt/dev/cfg/Condition

I googled around and found out that I need to include gwt-dev in my pom, and I did that, ran the test again, now it threw error:

我搜索了一下,发现我需要在我的 pom 中包含 gwt-dev,我这样做了,再次运行测试,现在它抛出了错误:

[ERROR] Unable to find 'Sample.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

[ERROR] Unable to find 'Sample.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

采纳答案by TheSolarSheriff

I found Eclipse's Run ConfigurationClasspathtab worked for me.

我发现 Eclipse 的Run ConfigurationClasspath选项卡对我有用。

You might already have an entry like java - appnameis/src/main/

您可能已经有一个条目,例如 java - appnameis/src/main/

It seems a pointless hack but the following worked for me

这似乎是一个毫无意义的黑客,但以下对我有用

Press the Green "Play" button > Run configurations> Classpathtab

按绿色的“播放”按钮 > Run configurations>Classpath选项卡

Select one of the User Entriese.g. java - appnameis/src/main/

选择其中之一,User Entries例如java - appnameis/src/main/

Select the Advancedbutton

选择Advanced按钮

Select Add Foldersdrill down to appnameis/src/main/java/app/nameOK

选择Add Folders向下钻取appnameis/src/main/java/app/nameOK

You now have entries like:

您现在有以下条目:

java - appnameis/src/main/

java - appnameis/src/main/

is - appnameis/src/main/java/app/name

is - appnameis/src/main/java/app/name

Where your appnameis.gwt.xmlfile is directly under the isfolder

您的appnameis.gwt.xml文件直接位于is文件夹下的位置

Run

Run

回答by Moshe

Check under Run Configurationsin Eclipse, and check the Argumentstab. If the class is moved, Eclipse won't update the command line arguments.

Run Configurations在 Eclipse下检查,并检查Arguments选项卡。如果类被移动,Eclipse 将不会更新命令行参数。

回答by dj18

If you're running the test from a launch file you might need to include your module in the launch classpath, for example:

如果您从启动文件运行测试,您可能需要在启动类路径中包含您的模块,例如:

<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
    <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;Sample&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
</listAttribute>