2013-10-26 99 views
1

我在我的GWT網絡應用中使用客戶端驗證,Maven作爲構建工具。在開發模式下運行不會導致任何問題。現在我想用Maven建項目,但得到多個錯誤,如下:gwt-maven-plugin無法編譯,因爲「沒有源代碼可用於類型org.hibernate.validator.constraints.impl.SizeValidatorForString;」

[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源文件休眠 - 驗證 - 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> 

加入休眠 - 驗證 - 4.2.0.Final-sources.jar休眠 - 驗證 - 4.2.0.Final-sources.jar MVN全新安裝後結果:

[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

沒有看到你的pom.xml這是一個有點很難說,但我的第一個假設是,你忘了添加對hiberna依賴te-validator-4.2.0.Final-sources.jar在您的pom中或者存在版本控制問題。你能發佈你的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罐子,但你沒有4.2.0.Final-sources.jar

添加最終來源的依賴關係,你應該有你的答案。

+0

所以這裏是'pom.xml'。實際上,我試着在pom中添加** hibernate-validator-4.2.0.Final-sources.jar **以及** hibernate-validator-4.2.0.Final.jar **,但它沒有幫幫我。 –

+0

你是否打掃乾淨? –

+0

獲取GA源代碼,並確保它們位於客戶端和服務器的類路徑中 –

0

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

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

注:顯然,服務器端驗證,你可以使用任何你想要的Hibernate驗證的版本。

+0

感謝您的回答!在'/ war/WEB-INF/lib'中用** 4.1.0.Final **替換了Hibernate Validator ** 4.2.0.Final **後,'GWT'成功編譯了項目。但是如何配置'pom.xml'來讓Maven構建項目呢? –

0

,你需要在你的類路徑都:冬眠 - 驗證 - 4.2.0.Final-sources.jar和休眠 - 驗證 - 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> 
相關問題