【问题标题】:JAXB schemagen doesn't reference classes in episode fileJAXB schemagen 不引用剧集文件中的类
【发布时间】:2016-04-19 09:24:23
【问题描述】:

我实际上使用的是模式优先方法,但是我遇到了“不祥”JAXB Map problem 的障碍!并通过切换到代码优先的方法来解决这个问题。现在我想在其他模块中重用这种类型,并通过从生成的模式创建一个插曲文件来继续我的模式优先方法。不幸的是,生成的剧集文件是空的。这是我尝试过的:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>2.2</version>
    <executions>
        <execution>
            <id>schemagen</id>
            <goals>
                <goal>schemagen</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>
    <configuration>
        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
        <generateEpisode>true</generateEpisode>
        <transformSchemas>
            <transformSchema>
                <uri>http://some/schema/types</uri>
                <toPrefix>core</toPrefix>
                <toFile>core-types.xsd</toFile>
            </transformSchema>
        </transformSchemas>
    </configuration>
</plugin>

这为我生成了以下架构:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:core="http://some/schema/types" targetNamespace="http://some/schema/types" version="1.0">
  <xs:element name="Map" type="core:MapType"/>

  <xs:complexType name="MapType">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="entries" nillable="true" type="core:EntryType"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="EntryType">
    <xs:sequence>
      <xs:element name="key" type="xs:anyType"/>
      <xs:element name="value" type="xs:anyType"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

还有一个包含此内容的剧集文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:bindings version="2.1" xmlns:ns1="http://java.sun.com/xml/ns/jaxb"/>

我尝试单独使用 schemagen(版本 2.2.11),结果相似。 https://jaxb.java.net/2.2.4/docs/schemagen.htmlhttp://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/schemagen-mojo.html 接缝处的文档表明应该是这样,但我无法弄清楚我做错了什么。

【问题讨论】:

  • 我遇到了同样的问题。不幸的是,这是一个错误。我做了一个修复并在 git 上创建了一个拉取请求。你可以在这里找到更多信息:java.net/jira/browse/JAXB-1110

标签: java jaxb jaxb2 jaxb2-maven-plugin schemagen


【解决方案1】:

我解决了问题...按照上面的操作:

    <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxb2-maven-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <id>schemagen</id>
                            <goals>
                                <goal>schemagen</goal>
                            </goals>
                            **<phase>generate-sources</phase>**
                        </execution>
                    </executions>

                    <configuration>             

                    **<xsdPathWithinArtifact>generated/xsds</xsdPathWithinArtifact>**

</configuration>


    </plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 2011-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多