2011-05-17 101 views
0

我有一个pom.xml,用于从模式生成源代码并进行绑定和编译。JiBx Maven构建问题

<!-- <plugin> 
      <groupId>org.jibx</groupId> 
      <artifactId>maven-jibx-plugin</artifactId> 
      <version>1.2.1.1</version> 
      <configuration> 
      <directory>src/main/resources/schema</directory> 
      </configuration> 
      <executions> 
      <execution> 
      <goals> 
      <goal>schema-codegen</goal> 
      </goals> 
      </execution> 
      </executions> 
      </plugin> --> 
      <plugin> 
      <groupId>org.jibx</groupId> 
      <artifactId>maven-jibx-plugin</artifactId> 
      <version>1.2.1.1</version> 
      <configuration> 
       <targetDirectory></targetDirectory> 
       <directory>src/main/resources/jibx</directory> 
       <includes> 
        <includes>*binding.xml</includes> 
       </includes> 
       <excludes> 
        <exclude>template-binding.xml</exclude> 
       </excludes> 
       <verbose>false</verbose> 
      </configuration> 
      <executions> 
       <execution> 
        <goals> 
         <goal>bind</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>compile-binding</id> 
       </execution> 

      </executions> 
     </plugin> 

所以当我尝试生成.java和binding.xml时,我取消注释的第一部分和注释的底部。这会生成.java和binding.xml。 现在,我将binding.xml复制到src/main/resources/jibx和java类到com.models.response package。然后,我通过取消注释这些行并评论顶部部分来运行绑定和编译绑定目标。我可以在'target.com.models.response'包中看到JiBX_bindingFactory.class和'JiBX_bindingResponse_access.class'。

问题是当我运行测试类并尝试将响应输入流解组为“Response.class”时,出现Exception in thread "main" org.jibx.runtime.JiBXException: JiBx Exception: Unable to access binding information for class com.models.response.Response Make sure the binding has been compiled 错误。

请注意:我在Eclipse中完成了这一切,并且默认输出文件夹显示'/ build'。我也尝试将Jibx类复制粘贴到'build'文件夹中。仍然面临同样的问题。

请帮忙!!!!!

谢谢

回答

0

两件事。

注释和取消注释pom部分不是开发的理想方法。看起来你并没有将这些目标限制在相关的Maven生命周期阶段。例如schema-codegenprocess-resources

由于maven jibx插件documentation指定,您需要针对测试运行以下目标。

jibx:test-bind Runs the JiBX binding compiler on the test classes. 
jibx:test-schema-codegen Generates Java test sources from XSD schemas. 
+0

现在是固定的。在Eclipse中,我的输出文件夹与POM.xml输出文件夹和Build Automatically ON文件夹的文件夹相同。所以每次生成JibX绑定类时,eclipse都会用java类文件替换它。 – narayanan 2011-05-24 06:32:50

+0

@narayanan这是什么修复?你是否最终改变了JIBX绑定输出的目标目录? – Skeeterdrums 2018-02-02 21:21:55