我有一个pom.xml,我用它从模式生成源代码,并进行绑定和编译。
<!-- <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’。
问题是,当我运行一个测试类并试图将响应inputstream解组到"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‘文件夹中。仍然面临着同样的问题。
请救命!
谢谢
发布于 2011-05-18 14:55:31
两件事。
注释和取消注释pom部分不是进行开发的理想方式。看起来您还没有将这些目标绑定到相关的maven生命周期阶段。例如,从schema-codegen到process-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.https://stackoverflow.com/questions/6036345
复制相似问题