Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jibx Maven插件:在不同的构建执行中转换模式时,模式之间的交叉引用_Java_Maven_Jibx - Fatal编程技术网

Java Jibx Maven插件:在不同的构建执行中转换模式时,模式之间的交叉引用

Java Jibx Maven插件:在不同的构建执行中转换模式时,模式之间的交叉引用,java,maven,jibx,Java,Maven,Jibx,我使用jibx Maven插件将一些XSD转换为Java源代码。在模式a中,有一个对模式B中定义的类型的引用。在此之前,我使用了这个pom.xml配置,一切正常: <plugin> <groupId>org.jibx</groupId> <artifactId>jibx-maven-plugin</artifactId> <version>1.2.3</version> <c

我使用jibx Maven插件将一些XSD转换为Java源代码。在模式a中,有一个对模式B中定义的类型的引用。在此之前,我使用了这个pom.xml配置,一切正常:

<plugin>
    <groupId>org.jibx</groupId>
    <artifactId>jibx-maven-plugin</artifactId>
    <version>1.2.3</version>
    <configuration>
        <schemaLocation>${basedir}/resources/oxm/schemas</schemaLocation>
        <schemaBindingDirectory>${basedir}/src/java</schemaBindingDirectory>
        <includeSchemas>
            <includeSchema>schemaA.xsd</includeSchema>
            <includeSchema>schemaB.xsd</includeSchema>
            <includeSchema>schemaC.xsd</includeSchema>
        </includeSchemas>
        <verbose>true</verbose>
     </configuration>
 </plugin>
最近,我在pom.xml中分离了不同构建执行中模式的转换,以便能够为它们定义不同的目标包。我的新pom.xml是:

<plugin>
    <groupId>org.jibx</groupId>
    <artifactId>jibx-maven-plugin</artifactId>
    <version>1.2.3</version>
    <configuration>
        <schemaLocation>${basedir}/resources/oxm/schemas</schemaLocation>
        <schemaBindingDirectory>${basedir}/src/java</schemaBindingDirectory>
        <verbose>true</verbose>
     </configuration>
     <executions>
         <execution>
             <id>schemaCodegenA</id>
             <goals>
                 <goal>schema-codegen</goal>
             </goals>
             <configuration>
                 <includeSchemas>
                     <includeSchema>schemaA.xsd</includeSchema>
                  </includeSchemas>
                  <options>
                      <package>com.myApp.jibxgenerated.schema.resource</package>
                  </options>
              </configuration>
          </execution>
这是预期的行为吗?我想把classB引用放回class A源代码中,有什么方法可以实现这一点吗

提前感谢您的帮助。

用户1550682

实际上,JiBX很容易处理这种情况。您可以将每个模式打包在一个单独的jar中,并使用maven插件轻松地引用子模块

请参阅此处的模块化模式说明:

请看github中的示例代码:

这个例子使用了三个简单的模式:公司->地址->人。并进行了一个简单的测试,对一些xml进行封送和解封

我希望这有帮助


Don

我发现这个问题是由使用Jibx maven插件提供给Jibx的定制xml中的首选内联属性生成的。我尽可能使用这个attrib来创建内部类,但显然它有时也内联属性。我不知道用于内联代码的启发式方法,因为它不会发生在我创建的简单测试用例中,非常类似于这里提到的模式(2个模式,其中一个导入另一个,前者使用后者定义复杂类型)。此外,如b4所述,当所有模式都在一次执行中处理时,问题不会发生。谢谢您的回答。这似乎需要很多额外的工作(为每个模式创建一个jar和一个pom)。我只是希望Maven jibx插件不要基于模式名称空间创建Java包,它应该允许我为每个模式定制目标包。在另一个xml模式中包含/导入一个xml模式以前工作得很好,但当我在几个构建执行中拆分源代码生成时,它就坏了(这是我发现的使用自定义Java包的唯一方法)。此外,在customization.xml中启用了Preference inline attrib;如果我关闭它,问题就解决了,但是我失去了内部类。
class classA
{
    classB objB;
    int foo;
}
<plugin>
    <groupId>org.jibx</groupId>
    <artifactId>jibx-maven-plugin</artifactId>
    <version>1.2.3</version>
    <configuration>
        <schemaLocation>${basedir}/resources/oxm/schemas</schemaLocation>
        <schemaBindingDirectory>${basedir}/src/java</schemaBindingDirectory>
        <verbose>true</verbose>
     </configuration>
     <executions>
         <execution>
             <id>schemaCodegenA</id>
             <goals>
                 <goal>schema-codegen</goal>
             </goals>
             <configuration>
                 <includeSchemas>
                     <includeSchema>schemaA.xsd</includeSchema>
                  </includeSchemas>
                  <options>
                      <package>com.myApp.jibxgenerated.schema.resource</package>
                  </options>
              </configuration>
          </execution>
class classA
{
    // all properties of class B here
    int classBattrib1;
    int classBattrib2;
    int classBattribN;
    int foo;
}