2010-08-31 122 views
11

我使用安裝了m2eclipse和GWT Eclipse插件的Eclipse 3.5(Galileo)。我使用gwt-maven-plugin原型創建了一個項目。我已經創建與這些類定義的RPC服務:GWT Maven Eclipse插件 - 由於重複類而編譯失敗

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

當運行mvn clean,目標目錄被刪除(如exepected)。當我運行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類作爲執行目標的一部分進行復制。那麼,爲什麼現在的目標會抱怨重複的課程呢?

任何幫助,非常感謝!

回答

32

我發現this posting其中規定:

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

此修復程序是從我的pom.xml刪除<goal>generateAsync</goal>。插件配置現在看起來像:

<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> 
5

您可能實際上已經生成了重複的類。

pom.xml中有一個「generateAsync」目標,它負責爲您創建的每個服務生成Async類。如果你有這個你不需要手動創建一個異步版本。

如果你這樣做,那麼你會得到「重複類」的錯誤。