我在我的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)
....................................................
答案 0 :(得分: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
添加最终来源的依赖关系,您应该得到答案。
答案 1 :(得分:0)
您需要Hibernate Validator 4.1(不是4.0,而不是4.2)。
请参阅https://code.google.com/p/google-web-toolkit/issues/detail?id=7661
注意:显然,对于服务器端验证,您可以使用任何版本的Hibernate Validator。