2013-04-02 106 views
3

我想使用GWT valiation 模塊(jsr303)使用新驗證的API(1.1)和Hibernate驗證器(5.0),但是,明顯得到了麻煩與GWT驗證

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目前沒有驗證API 1.1支持。

解決方法的任何想法?

+1

查詢+1。歡迎來到stackoverflow。你是對的GWT模擬客戶端的hibernate驗證器,目前正在使用4.1,因此validation-api版本是1.0而不是1.1。 – SSR

回答

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> 
3

你也許是領先的曲線在使用Hibernate 5 !!!!

GWT只支持休眠4.1.0.Final。這裏是從GWT樣本中剪下的maven pom.xml文件,內容爲Validation

<!-- 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已經移植了hibernate驗證器代碼來與客戶端一起工作。你可以在這裏找到它 - https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/org/hibernate/validator

你可以嘗試黑客周圍支持hibernate 5和validation-api 1.1!