2016-04-19 2 views
6

実際にはスキーマの最初のアプローチを使用していますが、「不快な」JAXB Map problemのロードブロッキングが発生しました。この問題のコードの第1のアプローチに切り替えることで、その問題を解決しました。今、私はこのタイプを他のモジュールで再利用し、生成されたスキーマからエピソードファイルを作成することでスキーマの最初のアプローチを続けたいと思います。残念ながら、生成されたエピソードファイルは空です。 (私はschemagenをスタンドアロンで使用しようとしたJAXB schemagenはエピソードファイルのクラスを参照しません

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

バージョン:

<?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> 

そして、このコンテンツとエピソードファイル:

<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> 

これは私に次のスキーマを生成:ここに私が試したものです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の縫い目の文書がありますが、間違っていることを理解できません。

+1

を私は同じ問題を抱えていました。残念ながらそれはバグです。私は修正を行い、gitでプルリクエストを作成しました。詳細はこちらをご覧ください:https://java.net/jira/browse/JAXB-1110 – snakebyte

答えて

0

私はこの問題を解決する...上記は、次のとおりです。

<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> 
関連する問題