与maven的XJC情节

时间:2012-03-29 15:25:48

标签: java maven jaxb cxf xjc

如何使用maven生成一集?我现在收到一条错误消息:an operand is missing (org.apache.cxf:cxf-xjc-plugin:2.4.0:xsdtojava:generate-sources:generate-sources)

这是我的插件:

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-plugin</artifactId>
            <version>2.4.0</version>
            <configuration>
                <extensions>
                    <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.4.0</extension>
                </extensions>
            </configuration>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xsdtojava</goal>
                    </goals>
                    <configuration>
                        <xsdOptions>
                            <xsdOption>
                                <extension>true</extension>
                                <xsd>my.xsd</xsd>
                                <packagename>mypackage</packagename>
                                 <extensionArgs>
                                  <arg>-episode</arg>
                                 </extensionArgs>
                            </xsdOption>
                        </xsdOptions>
                    </configuration>

                </execution>
                <execution>
                 <configuration>
                        <xsdOptions>
                 <xsdOption>
                        <extension>true</extension>
                          <xsd>my.xsd</xsd>
                        <extensionArgs>
                            <arg>-Xdv</arg>
                        </extensionArgs>
                    </xsdOption>
                        </xsdOptions>
                    </configuration>

                </execution>


            </executions>

编辑:该剧集的制作工作正常。在另一个项目中,包含该集的jar文件通过episodes属性给出。但我得到一个例外:Error while parsing schema(s).Location [ file:/D:/workspace/XXX/src/test/resources/XXX.xsd{45,32}]. om.sun.istack.SAXParseException2: compiler was unable to honor this conversion customization. It is attached to a wrong place, or its inconsistent with other bindings. nested in com.sun.istack.SAXParseException2: (the above customization is attached to the following location in the schema)

哪个是包含在最终产品中的剧集信息的xsd。它在该行上的一些xjc:javaType适配器引用。这会导致问题吗?

1 个答案:

答案 0 :(得分:1)

不同的插件来自你正在使用的东西,但是下面的剪辑曾经在几年前为我工作。您可能想看看是否有更新版本的插件等。如果不需要,还可以调整使用您的架构并删除绑定自定义。

  <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.7.0</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <schemaDirectory>${basedir}/src/main/xsd</schemaDirectory>
      <schemaIncludes>
        <schemaInclude>Core.xsd</schemaInclude>
      </schemaIncludes>
      <bindingDirectory>${basedir}/src/main/xjb</bindingDirectory>
      <bindingIncludes>
        <bindingInclude>JaxbBindings.xjb</bindingInclude>
      </bindingIncludes>
      <generateDirectory>${project.build.directory}/generated-sources/jaxb</generateDirectory>
      <episode>true</episode>
      <episodeFile>${project.build.directory}/generated-sources/jaxb/META-INF/sun-jaxb.episode</episodeFile>
      <verbose>true</verbose>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.1.10</version>
      </dependency>
      <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb-xjc</artifactId>
        <version>2.1.10</version>
      </dependency>
    </dependencies>
  </plugin>