Java gwt maven插件无法编译,因为“没有可用于org.hibernate.validator.constraints.impl.SizeValidatorForString类型的源代码;”
我在GWT web应用程序中使用客户端验证,并将Maven用作构建工具。在开发模式下运行不会导致任何问题。现在我想用Maven构建项目,但会出现如下多个错误:Java gwt maven插件无法编译,因为“没有可用于org.hibernate.validator.constraints.impl.SizeValidatorForString类型的源代码;”,java,maven,gwt,jar,Java,Maven,Gwt,Jar,我在GWT web应用程序中使用客户端验证,并将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.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插件在编译项目时能够看到jar源文件hibernate-validator-4.2.0.Final-sources.jar。如何管理此资源以使其正常工作?我曾尝试将hibernate-validator-4.2.0.Final-sources.jar放入src/main/resources目录,但似乎不起作用
pom.xml
在没有看到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
添加对最终源的依赖项,您应该会得到答案。您需要的是Hibernate Validator 4.1而不是4.0,也不是4.2 看
注意:显然,对于服务器端验证,您可以使用您想要的任何版本的Hibernate Validator。您的类路径中都需要有: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>
这里是pom.xml。事实上,我已经尝试在pom中添加hibernate-validator-4.2.0.Final-sources.jar和hibernate-validator-4.2.0.Final.jar,但没有帮助。你也清理和构建了吗?也获取GA源代码,并确保它们都位于客户端和服务器的类路径中我不确定,但是将hibernate-validator-4.2.0.Final-sources.jar和hibernate-validator-4.2.0.Final.jar依赖项添加到pom中似乎是错误的。我已经更新了错误堆栈跟踪。你为什么使用=系统?谢谢你的回答!在/war/WEB-INF/lib中将Hibernate Validator 4.2.0.Final替换为4.1.0.Final之后,GWT成功地编译了项目。但是如何配置pom.xml使Maven构建项目呢?
<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>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>