JiBx Maven构建问题

时间:2011-05-17 19:55:29

标签: build maven compilation jibx

我有一个pom.xml,用于从schema生成源代码并绑定和编译。

<!--  <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中完成所有这些操作,默认的Output文件夹显示'/ build'。我也尝试将Jibx类复制粘贴到'build'文件夹中。仍面临同样的问题。

请帮忙!!!!!

由于

1 个答案:

答案 0 :(得分: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.