简体   繁体   English

如何在Maven中关闭GWT异步RPC接口的自动生成

[英]How to turn off auto-generation of the GWT Asynchronous RPC interface in Maven

I'm working with a Java RPC service to communicate between the server and client side in my GWT application. 我正在使用Java RPC服务在GWT应用程序中的服务器和客户端之间进行通信。 I don't want to remove the asynchronous interface from my version control, because it's required in order for the project to compile and run. 我不想从版本控制中删除异步接口,因为为了使项目编译和运行,它是必需的。

However, the Async interface gets generated automatically (along with the Messages class) in the target/generated-sources folder by a Maven plugin, and I get a duplicate class error when the application tries to run. 但是,异步接口是由Maven插件在target / generated-sources文件夹中自动生成的(以及Messages类),并且在应用程序尝试运行时出现重复的类错误。

Does anybody know how to disable the auto-generation of the Asynchronous RPC interface? 有谁知道如何禁用异步RPC接口的自动生成?

I found the answer by following this question: 我通过以下问题找到了答案:

How to configure IntelliJ IDEA and/or Maven to automatically add directories with Java source code generated using jaxb2-maven-plugin? 如何配置IntelliJ IDEA和/或Maven以使用jaxb2-maven-plugin生成的Java源代码自动添加目录?

And then looking at the Maven GWT plugin at Mojo's website: 然后在Mojo的网站上查看Maven GWT插件:

http://mojo.codehaus.org/gwt-maven-plugin/user-guide/async.html http://mojo.codehaus.org/gwt-maven-plugin/user-guide/async.html

... so it wasn't IDEA that was generating the code, but rather it was the GWT Maven plugin. ...因此并不是IDEA生成代码,而是GWT Maven插件。 I disabled the auto-generation of the Async RPC and i18n Messages interfaces by commenting out the following two lines in my pom: 通过在pom中注释掉以下两行,我禁用了异步RPC和i18n消息接口的自动生成:

<goal>i18n</goal>
<goal>generateAsync</goal>

so that the plugin definition in pom.xml now looks like: 这样pom.xml中的插件定义现在看起来像:

 <plugin>
   <groupId>org.codehaus.mojo</groupId>
      <artifactId>gwt-maven-plugin</artifactId>
        <version>2.5.0</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>test</goal>
              <!--<goal>i18n</goal>-->
              <!--<goal>generateAsync</goal>-->
            </goals>
 . . .

And the problem is solved. 问题就解决了。

Actually commenting your POM is not the best way to do it. 实际上,评论您的POM并不是最好的方法。 I don't know about IDEA but with Eclipse "run configurations" you can specify the goals you want to execute. 我不了解IDEA,但是使用Eclipse“运行配置”可以指定要执行的目标。 I guess IDEA must have something similar (see link) . 我想IDEA一定有类似的东西(请参阅链接)

For instance I would have two distinct runners. 例如,我将有两个不同的跑步者。 One with the goals 一个目标

gwt:generateAsync gwt:i18n gwt:css

and one with no specific goals, which will execute a full build. 而没有具体目标的人将执行完整构建。

clean install

In your case you would want to have 在您的情况下,您希望拥有

gwt:compile gwt:test

If you NEVER want to execute the gwt:generateAsync goal though, removing it might be considered as a good option. 但是,如果您从不想执行gwt:generateAsync目标,则将其删除可能是一个不错的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM