3

我正在尝试使用新的验证 API(1.1)和 Hibernate 验证器(5.0)来使用 gwt 验证模块(jsr303 ),但是,显然得到了

ERROR: Errors in 'file:/C:/projects/qiwi-digest/webui/trunk/src/main/java/ru/befree/qiwi/client/gin/SampleValidatorFactory.java'
  ERROR: Line 27: No source code is available for type javax.validation.ParameterNameProvider; did you forget to inherit a required module?
  ERROR: Line 27: The method getParameterNameProvider() of type SampleValidatorFactory must override or implement a supertype method
  ERROR: Line 28: No source code is available for type org.hibernate.validator.internal.engine.DefaultParameterNameProvider; did you forget to inherit a required module?
  ERROR: Line 32: The method close() of type SampleValidatorFactory must override or implement a supertype method

即 GWT 当前不支持 Validation API 1.1。

任何解决方法的想法?

4

2 回答 2

3

您可能在使用 Hibernate 5 方面走在了前面!!!!

GWT 仅支持 hibernate 4.1.0.Final 。这是Validation的 GWT 示例中的 maven pom.xml 的片段。

   <!-- Hibernate bean validation binary for the server -->

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.1.0.Final</version>
      <exclusions>
        <exclusion>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Hibernate bean validation source for the GWT client -->

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.1.0.Final</version>
      <classifier>sources</classifier>
      <exclusions>
        <exclusion>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

GWT 已移植休眠验证器代码以与客户端一起使用。你可以在这里找到它 - https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/org/hibernate/validator

你可以尝试破解这个来支持hibernate 5和validation-api 1.1 !!!

于 2013-04-04T17:16:51.667 回答
1

您是否在路径中添加了 javax.validation-api 源?如果您使用 maven,您的依赖项应如下所示:

<dependency>
  <groupId>javax.validation</groupId>
  <artifactId>validation-api</artifactId>
  <version>1.0.0.GA</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>javax.validation</groupId>
  <artifactId>validation-api</artifactId>
  <version>1.0.0.GA</version>
  <classifier>sources</classifier>
  <scope>test</scope>
</dependency>
于 2013-04-02T10:10:31.557 回答