2013-06-22 4 views
3

Я хочу добавить globalBinding для сгенерированных типов schema.xsd в отдельный файл привязки schema.xjb. Я использую IntelliJ и не уверен, является ли эта проблема maven или Intellij (потому что этот пример выполняется, как ожидается, в eclipse, например). Ошибки я получаю:IntelliJ bindingDirectory для jaxb-maven-plugin

org.xml.sax.SAXParseException; systemId: file:/D:/Projects/Location/To/Project/src/main/resources/xsd/schema.xsd; lineNumber: 7; columnNumber: 10; vendor extension bindings (jaxb:extensionBindingPrefixes) are not allowed in the strict mode. Use -extension. 

Вот построить элемент в моей pom.xml:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>jaxb2-maven-plugin</artifactId> 
      <version>1.5</version> 
      <executions> 
       <execution> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>xjc</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <!-- The name of your generated source package --> 
       <packageName>com.my.model.example</packageName> 
        <schemaDirectory>${project.basedir}/src/main/resources/xsd</schemaDirectory> 
       <!-- Well Intellij acts badly when it comes down to binding files, so there is that. --> 
       <bindingDirectory>${project.basedir}/src/main/resources/xjb</bindingDirectory> 
      </configuration> 
     </plugin> 

    </plugins> 

</build> 

Вот моя схема находится в/SRC/главная/ресурсы/XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      id="SampleSchema" 
      targetNamespace="http://sample.com/namespace" 
      elementFormDefault="qualified" 
      xmlns="http://sample.com/namespace" 
     > 

    <xs:element name="Example"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element name="name" type="xs:string" maxOccurs="unbounded" /> 
       <xs:element name="street" type="xs:string"/> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 

</xs:schema> 

Вот мой bindingFile находится в/SRC/главная/ресурсы/xjb

<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
      version="2.0" 
      xsi:schemaLocation="../xsd/schema.xsd"> 
    <jxb:globalBindings> 
     <xjc:simple/> 
    </jxb:globalBindings> 
</jxb:bindings> 

Любые подсказки, как решить это было бы здорово!

ответ

9

Хорошо, ребята, я нашел то, что кажется проблемой. Я отсутствовал элемент <extension> в моем <configuration> элемента в pom.xml! Например:

<configuration> 

<packageName>com.my.model.example</packageName> 
<schemaDirectory>${project.basedir}/src/main/resources/xsd</schemaDirectory> 
<bindingDirectory>${project.basedir}/src/main/resources/xjb</bindingDirectory> 

<!-- tada! --> 
<extension>true</extension> 
</configuration>