java - GWT Maven Eclipse 插件 - 由于类重复导致编译失败

标签 java eclipse gwt m2eclipse

我正在使用安装了 m2eclipse 和 GWT Eclipse 插件的 Eclipse 3.5 (Galileo)。我使用 gwt-maven-plugin 原型(prototype)创建了一个项目。我创建了一个用这些类定义的 RPC 服务:

my.package.client.DataService
my.package.client.DataServiceAsync
my.package.server.DataServiceImpl

当我运行 mvn clean 时,目标目录被删除(如预期的那样)。当我运行 gwt:compile gwt:run -X -e 时,出现错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project MyProject: Compilation failure
C:\Devel\EclipseProjects\MyProject\target\generated-sources\gwt\my\package\client\DataServiceAsync.java:[8,7] duplicate class: my.project.client.DataServiceAsync
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project MyProject: Compilation failure
C:\Devel\EclipseProjects\MyProject\target\generated-sources\gwt\my\package\client\DataServiceAsync.java:[8,7] duplicate class: my.project.client.DataServiceAsync


    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:581)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeForkedExecutions(DefaultLifecycleExecutor.java:685)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:560)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
C:\Devel\EclipseProjects\MyProject\target\generated-sources\gwt\my\package\client\DataServiceAsync.java:[8,7] duplicate class: my.project.client.DataServiceAsync


    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
    ... 16 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

失败后,目标目录已创建,目录结构如下,其中单个文件如下:

MyProject/target/generated-sources/gwt/my/project/client/DataServiceAsync.java

由于目标目录在运行 gwt:compile gwt:run -X -e 之前不存在,因此必须创建目录并复制 java 类作为执行目标的一部分。那么,为什么目标现在会提示重复类?

非常感谢任何帮助!

最佳答案

我找到了 this posting其中指出:

If you manually create the Async interface you must disable the generateAsync goal in the plugin configuration

修复是删除 <goal>generateAsync</goal>来 self 的 pom.xml。插件配置现在看起来像:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>1.2</version>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <runTarget>my.package.Application/Application.html</runTarget>
    </configuration>
</plugin>

关于java - GWT Maven Eclipse 插件 - 由于类重复导致编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3611775/

相关文章:

java - 如何使用 Unirest for Java 获取对象列表?

eclipse - 在 Eclipse 首选项中看不到 PHP 内容类型?

java - GWT Tomcat Apache 500 内部服务器错误

java - 如何将 Java varargs 与 GWT Javascript native 接口(interface)一起使用? (又名, "GWT has no printf()")

eclipse - 将现有文件夹添加到 Eclipse 项目 (STS)

google-chrome - GXT 2.3.1 无法在 google chrome 版本 48 上读取 null 的属性 'style'

java - 使用 Cucumber 时 Spring Boot 在嵌入式 Cassandra 之前加载,如何解决此问题?

java - 如何在服务器响应上写入文件对象而不在服务器上保存文件?

java - 接口(interface)实现访问修饰符不符合预期

java - 错误 : org. apache.hadoop.security.AccessControlException : Permission denied: user=root, access=READ_EXECUTE,