0

我被这一天困住了。我浏览了几乎所有可用于此问题的链接。我还按照https://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation#ValidationTool上的说明进行操作

我仍然收到该错误,不知道为什么。

我只是在这里发疯。请帮忙。这里还有什么遗漏的吗?

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <!-- POM file generated with GWT webAppCreator -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.kivar.lumina</groupId>
    <artifactId>client</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>GWT Maven Archetype</name>

    <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.5.1</gwtVersion>
        <!-- GWT needs at least java 1.5 -->
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>

        <!-- RequestFactory server -->

        <dependency>
            <groupId>com.google.web.bindery</groupId>
            <artifactId>requestfactory-server</artifactId>
            <version>${gwtVersion}</version>
        </dependency>

        <!-- Hibernate dependencies -->
        <!-- <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> 
            <version>1.0.0.GA</version> </dependency> <dependency> <groupId>org.hibernate</groupId> 
            <artifactId>hibernate-entitymanager</artifactId> <version>4.2.1.Final</version> 
            </dependency> -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.3.1.Final</version>
        </dependency>
        <!-- Required by Hibernate validator because slf4j-log4j is optional in 
            the hibernate-validator POM -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>

        <!-- Oracle JDBC driver -->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>


    </dependencies>

    <repositories>
        <repository>
            <id>codelds</id>
            <url>https://code.lds.org/nexus/content/groups/main-repo</url>
        </repository>
    </repositories>

    <build>
        <!-- Generate compiled stuff in the folder used for developing mode -->
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

        <pluginManagement>
            <plugins>
                <!-- GWT Maven Plugin -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>2.5.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>test</goal>
                                <goal>i18n</goal>
                                <goal>generateAsync</goal>
                            </goals>
                        </execution>
                    </executions>
                    <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
                        documentation at codehaus.org -->
                    <configuration>
                        <runTarget>Application.html</runTarget>
                        <hostedWebapp>${webappDirectory}</hostedWebapp>
                        <i18nMessagesBundle>com.kivar.lumina.client.Messages</i18nMessagesBundle>
                    </configuration>
                </plugin>

                <!-- Copy static web files before executing gwt:run -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>exploded</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <webappDirectory>${webappDirectory}</webappDirectory>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>

                <!-- RequestFactory Validation jar -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.google.web.bindery</groupId>
                            <artifactId>requestfactory-apt</artifactId>
                            <version>${gwtVersion}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

这里还有什么遗漏的吗?

4

3 回答 3

2

如评论中所述,您需要拥有“YourRequestFactory”DeobfuscatorBuilder.class 文件才能运行它。我有类似的问题,想要非 Eclipse 依赖的解决方案。我解决了它:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <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>

另一种选择是com.google.web.bindery.requestfactory.apt.ValidationTool直接使用该工具。您需要从 JDK java(不是 JRE)运行它并拥有

requestfactory-apt-2.5.1.jar requestfactory
-server-2.5.1.jar
你想要的 RequestFactory 类及其依赖项

在类路径上。将 2.5.1 替换为 ${gwtVersion}。你简单地运行它

java -cp <your_set_classpath> com.google.web.bindery.requestfactory.apt.ValidationTool <your wanna-be RequestFactory class to be validated> <another wannae-be factory>...

windows .bat 文件的示例(cd 到 JDK 目录以运行 JDK java 而不是 JRE java):

set loc=d:\coding\java\workspace\j2ee\beg_1\Allo\web\src\main\java\
set tool=d:\coding\tools\Maven\.m2\repository\com\google\web\bindery\requestfactory-apt\2.5.1\requestfactory-apt-2.5.1.jar
set server=d:\coding\tools\Maven\.m2\repository\com\google\web\bindery\requestfactory-server\2.5.1\requestfactory-server-2.5.1.jar
set lib=d:\coding\tools\Maven\.m2\repository\bbc\juniperus\allo-entities\1.0\allo-entities-1.0.jar
set lib2=d:\coding\tools\Maven\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.0-api\1.0.1.Final\hibernate-jpa-2.0-api-1.0.1.Final.jar

set CP=%loc%;%tool%;%server%;%lib%;%lib2%

cd %JAVA_HOME%/bin

java -cp %CP% com.google.web.bindery.requestfactory.apt.ValidationTool d:/output.jar bbc.juniperus.allo.web.gwt.client.CalendarRequestFactory"

此外,即使我不是 Maven 专家,我也不确定是否在 Maven 中拥有双重 maven-compiler-plugin 声明是否会导致在构建时不运行验证。

于 2013-08-04T11:24:54.867 回答
0

要在maven-compiler-plugin 3.*中运行,您需要一个额外的配置密钥:forceJavacCompilerUse. 完整的示例可能如下所示:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <forceJavacCompilerUse>true</forceJavacCompilerUse> </configuration> <dependencies> <dependency> <groupId>com.google.web.bindery</groupId> <artifactId>requestfactory-apt</artifactId> <version>2.6.1</version> </dependency> </dependencies> </plugin>

您不需要annotationProcessors配置部分,因为maven-compiler-plugin可以自动发现和应用 RequestFactory 注释处理工具。

于 2014-07-02T12:34:47.963 回答
0

当 GWT 应用程序从 Eclipse 或其他 IDE 启动时,似乎会发生此问题。在maven中我还没有看到它。

解决该问题的方法是使用 Maven 启动应用程序以创建xxx.yyyDeobfuscatorBuilder类,然后您可以从 Eclipse 启动 GWT 应用程序而不会出现问题

于 2016-10-16T08:05:26.840 回答