maven - 在 intellij 中运行 GWT 时出错

标签 maven tomcat gwt intellij-idea

我正在尝试在 Tomcat 服务器上运行 GWT,我的构建框架是 Maven。但是我不断收到以下错误

 java: Unable to find RequestFactory built-in type. Is requestfactory-[client|server].jar on the classpath?

知道为什么会这样吗?

谢谢

最佳答案

阅读此错误,似乎缺少一个库。检查 request-factory-server 是否在您的 pom.xml 中以及您的配置是否正确。

我也在使用 maven 和 GWT-requestfactory。这是我工作的 Maven 配置示例:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
<!-- -->
    </parent>
    <artifactId>docentryeditor</artifactId>
    <packaging>war</packaging>

    <name>doc-entry-editor</name>

    <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.5.1</gwtVersion>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>gwt-maven</id>
            <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
        </repository>
    </repositories>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.web.bindery</groupId>
            <artifactId>requestfactory-server</artifactId>
            <version>${gwtVersion}</version>
        </dependency>
        <dependency>
            <groupId>com.google.web.bindery</groupId>
            <artifactId>requestfactory-apt</artifactId>
            <version>${gwtVersion}</version>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
            <version>1.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-servlet</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>docentryeditor</finalName>
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
        <!-- Generate compiled stuff in the folder used for developing mode -->
        <!--<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>-->
        <plugins>
            <!-- GWT Maven Plugin-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwtVersion}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-user</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-dev</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-servlet</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                </dependencies>
                <!-- JS is only needed in the package phase, this speeds up testing -->
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <!-- Plugin configuration. There are many available options,
                     see gwt-maven-plugin documentation at codehaus.org -->
                <configuration>
                    <!-- URL that should be automatically opened in the GWT shell (gwt:run). -->
                    <runTarget>XDS-MetadataEditor.html</runTarget>
                    <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
                    <compileReport>true</compileReport>
                    <module>edu.tn.xds.metadata.editor</module>
                    <hostedWebapp>${webappDirectory}</hostedWebapp><!--makes file download work in dev mode-->
                    <logLevel>INFO</logLevel>
                    <style>${gwtVersion}</style>

                    <copyWebapp>true</copyWebapp>
                </configuration>
            </plugin>

            <!-- Maven WAR plugin -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <!-- configured to be the same as for the gwt plugin -->
                    <webappDirectory>${webappDirectory}</webappDirectory>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <!-- create an exploded version of the war in webappDirectory. Ideal
                                for development -->
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Copy static web files before executing gwt:run -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.2</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${webappDirectory}/WEB-INF/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/webapp</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- RequestFactory Validation jar -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <annotationProcessors>
                        <annotationProcessor>com.google.web.bindery.requestfactory.apt.RfValidator</annotationProcessor>
                    </annotationProcessors>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.google.web.bindery</groupId>
                        <artifactId>requestfactory-apt</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings
                                only. It has no influence on the Maven build itself. -->


        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.codehaus.mojo</groupId>
                                        <artifactId>
                                            gwt-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.5.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>i18n</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>
</project>

如果您有任何疑问或有任何不明白之处,请不要犹豫。 否则,如果您真的做不到,请将您的 Maven 配置提供给我,我会查看它并尝试告诉您哪里出了问题。

请注意,我的配置中没有 tomcat 配置,因为我不需要它,但我真的不认为这会是您的问题。

关于maven - 在 intellij 中运行 GWT 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24311158/

相关文章:

java - Maven 不会因编译器警告而失败

Eclipse 在部署 webapp 时忽略源

tomcat - 如何使用 xsbt-web-plugin 为每个 Spray 应用程序启动具有不同端口的多个 Tomcat 实例?

java - GET - 目前您无法在开发模式下引入新注释。请重新启动

android - Gradle Android 与 maven 存储库通信 身份验证错误

java - Eclipse&Maven - 导入org.hibernate.boot.无法解析

java - GWT:检查事件处理程序是否存在

java - 如何同时运行多个线程进行自动化 Selenium 测试?

java - 将 JHipster 应用程序上传到 Nexus Repository 3 不起作用

jsp - 在 Tomcat 网络应用程序中参数化 "static"内容(例如 CSS)的好方法是什么?