1

我在我的GWT网络应用程序中使用客户端验证,并Maven作为构建工具。在开发模式下运行不会导致任何问题。现在我想用 构建项目Maven,但得到多个错误,如下所示:

[ERROR] Line 52: No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForString; did you forget to inherit a required module?
[INFO]       [ERROR] Line 52: No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForCollection; did you forget to inherit a required module?
[INFO]       [ERROR] Line 52: No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForMap; did you forget to inherit a required module?
[INFO]       [ERROR] Line 75: No source code is available for type org.hibernate.validator.constraints.impl.NotNullValidator; did you forget to inherit a required module?
[INFO]       [ERROR] Line 83: No source code is available for type org.hibernate.validator.constraints.NotEmpty; did you forget to inherit a required module?

我希望在编译项目时gwt-maven-plugin能看到 jar 源文件hibernate-validator-4.2.0.Final-sources.jar 。如何管理此资源以使其正常工作?我试图将hibernate-validator-4.2.0.Final-sources.jar放入src/main/resources目录,但它似乎不起作用。

pom.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
        <groupId>com.szybieka.tarantula</groupId>
        <artifactId>parent</artifactId>
        <version>0.1</version>
    </parent>

    <artifactId>tarantula</artifactId>
    <packaging>war</packaging>

    <name>Tarantula</name>
    <url>http://github.com/shebeko/tarantula</url>

    <properties>
        <gwt.version>2.5.1</gwt.version>
        <jackson.version>1.9.10</jackson.version>
    </properties>

    <dependencies>

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

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

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}/war/WEB-INF/lib/hibernate-validator-4.2.0.Final.jar</systemPath>
        </dependency>


        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>system</scope>
            <systemPath>${basedir}/war/WEB-INF/lib/validation-api-1.0.0.GA.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
            <scope>system</scope>
            <systemPath>${basedir}/war/WEB-INF/lib/slf4j-api-1.6.1.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
            <scope>system</scope>
            <systemPath>${basedir}/war/WEB-INF/lib/json-20090211.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>


        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- Catcha from local repository -->
        <dependency>
            <groupId>com.google.code</groupId>
            <artifactId>captcha</artifactId>
            <version>1.2.1</version>
        </dependency>

        <!-- Jackson JSON processor -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.2.3</version>
        </dependency>


        <!-- Core  -->
        <dependency>
            <groupId>com.szybieka.tarantula</groupId>
            <artifactId>core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Location -->
        <dependency>
            <groupId>com.szybieka.tarantula</groupId>
            <artifactId>location</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Jackson JSON Mapper -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <!-- DataSource -->     
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>

        <finalName>tarantula</finalName>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>

        <plugins>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <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>${gwt.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1-beta-1</version>
                <configuration>
                    <warSourceDirectory>${basedir}/war</warSourceDirectory>
                    <archiveClasses>true</archiveClasses>
                    <warSourceExcludes>WEB-INF/classes/**,WEB-INF/lib/gwt-servlet*,gwtia_requestfactory_*/**</warSourceExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.3.0</version>
                <executions>
                    <execution>
                        <configuration>
                            <modules>
                                <param>com.szybieka.tarantula.gwt.MainModule</param>
                            </modules>
                        </configuration>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-user</artifactId>
                        <version>${gwt.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-dev</artifactId>
                        <version>${gwt.version}</version>
                    </dependency>
                </dependencies>
            </plugin>




        </plugins>

    </build>
</project>

添加hibernate-validator-4.2.0.Final-sources.jar hibernate-validator-4.2.0.Final-sources.jar mvn clean install结果如下:

[INFO] ------------------------------------------------------------------------
[INFO] Building Tarantula 0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ tarantula ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tarantula ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 50 source files to /home/adam-szybieka/workspace/tarantula/parent/web/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalProxy.java:[3,43] package org.hibernate.validator.constraints does not exist
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalFormProxy.java:[3,43] package org.hibernate.validator.constraints does not exist
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalProxy.java:[14,6] cannot find symbol
  symbol:   class NotEmpty
  location: interface com.szybieka.tarantula.gwt.client.proxy.PrincipalProxy
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalProxy.java:[19,6] cannot find symbol
  symbol:   class NotEmpty
  location: interface com.szybieka.tarantula.gwt.client.proxy.PrincipalProxy
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalFormProxy.java:[9,6] cannot find symbol
  symbol:   class NotEmpty
  location: interface com.szybieka.tarantula.gwt.client.proxy.PrincipalFormProxy
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalFormProxy.java:[14,6] cannot find symbol
  symbol:   class NotEmpty
  location: interface com.szybieka.tarantula.gwt.client.proxy.PrincipalFormProxy
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalFormProxy.java:[19,6] cannot find symbol
  symbol:   class NotEmpty
  location: interface com.szybieka.tarantula.gwt.client.proxy.PrincipalFormProxy
[ERROR] /home/adam-szybieka/workspace/tarantula/parent/web/src/main/java/com/szybieka/tarantula/gwt/client/proxy/PrincipalProxy.java:[15,12] java.util.NoSuchElementException
    at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:396)
....................................................
4

3 回答 3

0

没有看到你的 pom.xml 很难说,但我的第一个假设是你忘记在你的 pom 中添加对 hibernate-validator-4.2.0.Final-sources.jar 的依赖项,或者存在版本控制问题。你能发布你的pom吗?

知道了:

你有这个依赖

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <scope>system</scope>
        <systemPath>${basedir}/war/WEB-INF/lib/hibernate-validator-4.2.0.Final.jar</systemPath>
    </dependency>

这是 4.2.0.Final jar 但你没有 4.2.0.Final-sources.jar

添加对 final-sources 的依赖项,您应该得到答案。

于 2013-10-26T22:12:12.567 回答
0

您需要 Hibernate Validator 4.1(不是 4.0,不是 4.2)。

请参阅https://code.google.com/p/google-web-toolkit/issues/detail?id=7661

注意:显然,对于服务器端验证,您可以使用您想要的任何版本的 Hibernate Validator。

于 2013-10-27T08:37:28.627 回答
0

你需要在你的类路径中有:hibernate-validator-4.2.0.Final-sources.jar 和 hibernate-validator-4.2.0.Final.jar

只需将以下内容添加到您的 pom.xml 中:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0.Final</version>
    <classifier>sources</classifier>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0.Final</version>
</dependency>
于 2016-02-21T16:15:10.077 回答