出现错误,在使用maven-jaxb2-plugin的整个编译过程中仅允许一个globalBindings定制 [英] getting error only one globalBindings customization is allowed in a whole compilation while using maven-jaxb2-plugin

查看:94
本文介绍了出现错误,在使用maven-jaxb2-plugin的整个编译过程中仅允许一个globalBindings定制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用maven-jaxb2-plugin.这是我的插件配置

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc-serviceoperations</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java/</generateDirectory>
                <schemaDirectory>src/main/resources/schemas/lmsapi/serviceoperations</schemaDirectory>
                <removeOldOutput>false</removeOldOutput>
            </configuration>
        </execution>
        <execution>
            <id>xjc-types</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java</generateDirectory>
                <schemaDirectory>src/main/resources/schemas/lmsapi/types</schemaDirectory>
                <bindingDirectory>src/main/resources/schemas</bindingDirectory>
                <bindingIncludes>
                    <include>schema-binding.xjb</include>
                </bindingIncludes>
                <removeOldOutput>false</removeOldOutput>
            </configuration>
        </execution>
    </executions>
</plugin>   

这是我的schema-binding.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:annox="http://annox.dev.java.net"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb 
                    http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    version="2.1">

    <jaxb:globalBindings>
        <jaxb:javaType name="java.time.LocalDateTime" xmlType="xsd:dateTime"
            parseMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateTimeCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateTimeCustomBinder.printDateTime" />

    <jaxb:javaType name="java.time.LocalDate" xmlType="xsd:date"
            parseMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateCustomBinder.printDateTime" />

        <xjc:serializable uid="1" /> 
    </jaxb:globalBindings>

</jaxb:bindings>

我有一个xsd Enrollments.xsd.在其中我有日期类型.我希望任何具有日期或日期时间类型的xsd都转换为Localdate或Localdatetime而不是XMLGregorianCalendar.这是代码段

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com" 
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:include schemaLocation="Learner.xsd"/>
    ...
    <xsd:complexType name="LearnerEnrollCourses">  
        <xsd:sequence>  
            <xsd:element name="CourseId" type="xsd:string" minOccurs="1" maxOccurs="unbounded" nillable="false"  />
        </xsd:sequence> 
        <xsd:attribute name="enrollmentStartDate" type="xsd:date" use="required" />
         <xsd:attribute name="enrollmentEndDate" type="xsd:date" use="required" /> 
    </xsd:complexType>
    ...
</xsd:schema>

现在,当我右键单击POM时.选择Run As -> Maven generate-sources,然后出现以下错误

[INFO] Sources are not up-to-date, XJC will be executed.
[ERROR] Error while parsing schema(s).Location [ file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb{12,26}].
com.sun.istack.SAXParseException2; systemId: file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb; lineNumber: 12; columnNumber: 26; only one globalBindings customization is allowed in a whole compilation
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:86)
at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:84)
....
[ERROR] Error while parsing schema(s).Location [ file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb{12,26}].
com.sun.istack.SAXParseException2; systemId: file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb; lineNumber: 12; columnNumber: 26; (related to above) but one is already given at this location

尽管正在生成类.但是类型仍然是XMLGregorianCalendar.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LearnerEnrollCourses", propOrder = {
    "courseId"
})
public class LearnerEnrollCourses {

    @XmlElement(name = "CourseId", required = true)
    protected List<String> courseId;

    @XmlAttribute(name = "enrollmentStartDate", required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar enrollmentStartDate;

    @XmlAttribute(name = "enrollmentEndDate", required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar enrollmentEndDate;

我在配置中做错了什么以及如何解决?

谢谢

--------------------- EDIT ---------------------- -

此插件配置有效.

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc-serviceoperations</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java/</generateDirectory>
                <schemaIncludes>
                    <schemaInclude>schemas/lmsapi/serviceoperations/*.xsd</schemaInclude>
                </schemaIncludes>
                <bindingIncludes>
                    <bindingInclude>schemas/schema-binding.xjb</bindingInclude>
                </bindingIncludes>
                <verbose>true</verbose>
                <extension>true</extension>
                <removeOldOutput>false</removeOldOutput>
            </configuration>
        </execution>
        <execution>
            <id>xjc-types</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java</generateDirectory>
                <schemaDirectory>schemas/lmsapi/types</schemaDirectory>
                <schemaIncludes>
                    <schemaInclude>**/*.xsd</schemaInclude>
                </schemaIncludes>
                <schemaExcludes>
                    <schemaExclude>Enrollment.xsd</schemaExclude>
                </schemaExcludes>
                <removeOldOutput>false</removeOldOutput>
                <verbose>true</verbose>
                <extension>true</extension>
            </configuration>
        </execution>
    </executions>
</plugin>

这是我的schema-binding.xjb

<jaxb:globalBindings>

    <jaxb:javaType name="java.time.LocalDateTime" xmlType="xsd:dateTime"
            parseMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateTimeCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateTimeCustomBinder.printDateTime" />

    <jaxb:javaType name="java.time.LocalDate" xmlType="xsd:date"
            parseMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateCustomBinder.printDateTime" />

    <!-- Force all classes implements Serializable -->
    <xjc:serializable uid="1" />

</jaxb:globalBindings>


<jaxb:bindings schemaLocation="lmsapi/types/Enrollment.xsd" node="/xsd:schema" >
    <jaxb:schemaBindings >
        <jaxb:package name="com.softech.vu360.lms.webservice.message.lmsapi.types.enrollment" />
    </jaxb:schemaBindings>
</jaxb:bindings>

这是我来自serviceoperations和types目录的文件之一

EnrollmentServiceOperations.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://enrollment.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://enrollment.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:enrolmnt="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
    <xsd:import namespace="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Enrollment.xsd"/>

    <xsd:element name="LearnerCoursesEnrollRequest">
        <xsd:complexType>
            ....
        </xsd:complexType>
    </xsd:element>
    ....
</xsd:schema>

CustomerServiceOperations.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:cust="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
    <xsd:import namespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Customer.xsd"/>

    <xsd:element name="AddCustomerRequest">
        <xsd:complexType>
            ...
        </xsd:complexType>
    </xsd:element>
    ...
</xsd:schema>

Types/Enrollment.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com" 
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:include schemaLocation="Learner.xsd"/>

    <xsd:complexType name="LearnerCourses">  
        ....  
    </xsd:complexType>
    ....
</xsd:schema>

types/Customer.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" 
    xmlns:addr="http://address.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:import namespace="http://address.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="Address.xsd"/>

    <xsd:complexType name="Customers">  
        <xsd:sequence>  
            ....
        </xsd:sequence>  
    </xsd:complexType>
    ...
</xsd:schema>

现在,当我运行Run As -> Maven generate-sources时.它将在src/main/java/com/..../serviceoperation/customer/AddCustomerRequest.java中生成serviceoperations源,并在src/main/java/com/.../types/customer/Customers.java中键入源.其他xsds也是如此.

为什么我不应该使用<generateDirectory>${basedir}/src/main/java/</generateDirectory>.这就是我要的.我认为这个插件是从每个xsd中的targetnamespace制作软件包的.我说的对吗?

如果我在配置此插件时做错了什么,请告诉我,以便我进行纠正.就像您说的不要在src/main/java中生成.

我希望我在serviceoperations文件夹(src/main/resources/schemas/lmsapi/serviceoperation/*.xsd)中的所有xsds都应该在src/main/java/com/..../serviceoperation/customer/*.javasrc/main/java/com/..../serviceoperation/enrollment/*.java文件夹中生成,并且其他文件也应相同.

(src/main/resources/schemas/lmsapi/types/*.xsd)中的所有xsds应该在src/main/java/com/..../types/customer/*.javasrc/main/java/com/..../types/enrollment/*.java文件夹中生成,其他文件也应相同.

我的绑定文件也适用于servieoperations和types文件夹中的所有xsds.

有没有更好的方法来配置此插件,请告诉我,以便我自己纠正.我猜你是这个插件的作者.

感谢&问候

Basit Mahmood Ahmed

解决方案

该问题的当前状态,以免其他人感到沮丧和搜索...

此问题是随机出现的,并且是由JAXB实现中的错误引起的.报告该问题 https://java.net/jira/browse/JAXB-687但是,尽管尚未修复,但现在已关闭(请参阅2016年9月16日发布的次优用户的评论).

I am using maven-jaxb2-plugin. Here is my plugin configuration

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc-serviceoperations</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java/</generateDirectory>
                <schemaDirectory>src/main/resources/schemas/lmsapi/serviceoperations</schemaDirectory>
                <removeOldOutput>false</removeOldOutput>
            </configuration>
        </execution>
        <execution>
            <id>xjc-types</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java</generateDirectory>
                <schemaDirectory>src/main/resources/schemas/lmsapi/types</schemaDirectory>
                <bindingDirectory>src/main/resources/schemas</bindingDirectory>
                <bindingIncludes>
                    <include>schema-binding.xjb</include>
                </bindingIncludes>
                <removeOldOutput>false</removeOldOutput>
            </configuration>
        </execution>
    </executions>
</plugin>   

here is my schema-binding.xml file

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:annox="http://annox.dev.java.net"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb 
                    http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    version="2.1">

    <jaxb:globalBindings>
        <jaxb:javaType name="java.time.LocalDateTime" xmlType="xsd:dateTime"
            parseMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateTimeCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateTimeCustomBinder.printDateTime" />

    <jaxb:javaType name="java.time.LocalDate" xmlType="xsd:date"
            parseMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.xsd.binder.XSDateCustomBinder.printDateTime" />

        <xjc:serializable uid="1" /> 
    </jaxb:globalBindings>

</jaxb:bindings>

I have an xsd Enrollments.xsd. In which I have date type. I want that any xsd with date or datetime type convert to Localdate or Localdatetime instead of XMLGregorianCalendar. here is the snippet

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com" 
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:include schemaLocation="Learner.xsd"/>
    ...
    <xsd:complexType name="LearnerEnrollCourses">  
        <xsd:sequence>  
            <xsd:element name="CourseId" type="xsd:string" minOccurs="1" maxOccurs="unbounded" nillable="false"  />
        </xsd:sequence> 
        <xsd:attribute name="enrollmentStartDate" type="xsd:date" use="required" />
         <xsd:attribute name="enrollmentEndDate" type="xsd:date" use="required" /> 
    </xsd:complexType>
    ...
</xsd:schema>

Now when I right click on POM. select Run As -> Maven generate-sources then I am getting the following error

[INFO] Sources are not up-to-date, XJC will be executed.
[ERROR] Error while parsing schema(s).Location [ file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb{12,26}].
com.sun.istack.SAXParseException2; systemId: file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb; lineNumber: 12; columnNumber: 26; only one globalBindings customization is allowed in a whole compilation
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:86)
at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:84)
....
[ERROR] Error while parsing schema(s).Location [ file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb{12,26}].
com.sun.istack.SAXParseException2; systemId: file:/D:/Basit/eclipse-jee-mars-2/workspace/360Training/Java%208/LS360ProxyAPI/LmsApiProxy/src/main/resources/schemas/schema-binding.xjb; lineNumber: 12; columnNumber: 26; (related to above) but one is already given at this location

Although classes are generating. But type is still XMLGregorianCalendar.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LearnerEnrollCourses", propOrder = {
    "courseId"
})
public class LearnerEnrollCourses {

    @XmlElement(name = "CourseId", required = true)
    protected List<String> courseId;

    @XmlAttribute(name = "enrollmentStartDate", required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar enrollmentStartDate;

    @XmlAttribute(name = "enrollmentEndDate", required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar enrollmentEndDate;

What I am doing wrong in configuration and how can I solve it ?

Thanks

---------------------EDIT-----------------------

This plugin configuration is working.

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc-serviceoperations</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java/</generateDirectory>
                <schemaIncludes>
                    <schemaInclude>schemas/lmsapi/serviceoperations/*.xsd</schemaInclude>
                </schemaIncludes>
                <bindingIncludes>
                    <bindingInclude>schemas/schema-binding.xjb</bindingInclude>
                </bindingIncludes>
                <verbose>true</verbose>
                <extension>true</extension>
                <removeOldOutput>false</removeOldOutput>
            </configuration>
        </execution>
        <execution>
            <id>xjc-types</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <generateDirectory>${basedir}/src/main/java</generateDirectory>
                <schemaDirectory>schemas/lmsapi/types</schemaDirectory>
                <schemaIncludes>
                    <schemaInclude>**/*.xsd</schemaInclude>
                </schemaIncludes>
                <schemaExcludes>
                    <schemaExclude>Enrollment.xsd</schemaExclude>
                </schemaExcludes>
                <removeOldOutput>false</removeOldOutput>
                <verbose>true</verbose>
                <extension>true</extension>
            </configuration>
        </execution>
    </executions>
</plugin>

here is my schema-binding.xjb

<jaxb:globalBindings>

    <jaxb:javaType name="java.time.LocalDateTime" xmlType="xsd:dateTime"
            parseMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateTimeCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateTimeCustomBinder.printDateTime" />

    <jaxb:javaType name="java.time.LocalDate" xmlType="xsd:date"
            parseMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateCustomBinder.parseDateTime"
            printMethod="com.softech.ls360.lms.api.proxy.schema.binder.XSDateCustomBinder.printDateTime" />

    <!-- Force all classes implements Serializable -->
    <xjc:serializable uid="1" />

</jaxb:globalBindings>


<jaxb:bindings schemaLocation="lmsapi/types/Enrollment.xsd" node="/xsd:schema" >
    <jaxb:schemaBindings >
        <jaxb:package name="com.softech.vu360.lms.webservice.message.lmsapi.types.enrollment" />
    </jaxb:schemaBindings>
</jaxb:bindings>

Here is my one of the files from serviceoperations and types directory

EnrollmentServiceOperations.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://enrollment.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://enrollment.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:enrolmnt="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
    <xsd:import namespace="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Enrollment.xsd"/>

    <xsd:element name="LearnerCoursesEnrollRequest">
        <xsd:complexType>
            ....
        </xsd:complexType>
    </xsd:element>
    ....
</xsd:schema>

CustomerServiceOperations.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:cust="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
    <xsd:import namespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Customer.xsd"/>

    <xsd:element name="AddCustomerRequest">
        <xsd:complexType>
            ...
        </xsd:complexType>
    </xsd:element>
    ...
</xsd:schema>

Types/Enrollment.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://enrollment.types.lmsapi.message.webservice.lms.vu360.softech.com" 
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:include schemaLocation="Learner.xsd"/>

    <xsd:complexType name="LearnerCourses">  
        ....  
    </xsd:complexType>
    ....
</xsd:schema>

types/Customer.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" 
    xmlns:addr="http://address.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:import namespace="http://address.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="Address.xsd"/>

    <xsd:complexType name="Customers">  
        <xsd:sequence>  
            ....
        </xsd:sequence>  
    </xsd:complexType>
    ...
</xsd:schema>

Now when I run Run As -> Maven generate-sources. It will generate serviceoperations sources in src/main/java/com/..../serviceoperation/customer/AddCustomerRequest.java and types sources in src/main/java/com/.../types/customer/Customers.java. Similar for others xsds.

Why shouldn't I use <generateDirectory>${basedir}/src/main/java/</generateDirectory>. This is what I want. I think this plugin is making packages from targetnamespace in each xsd. Am I right ?

If I am doing something wrong in configuring this plugin then please tell me so I can correct it. Like you said not to generate in src/main/java.

I want that all my xsds in serviceoperations folder (src/main/resources/schemas/lmsapi/serviceoperation/*.xsd) should generate in src/main/java/com/..../serviceoperation/customer/*.java, src/main/java/com/..../serviceoperation/enrollment/*.java folder and same for others.

All xsds in (src/main/resources/schemas/lmsapi/types/*.xsd) should generate in src/main/java/com/..../types/customer/*.java, src/main/java/com/..../types/enrollment/*.java folder and same for others.

And also my binding file apply to all xsds (src/main/resources/schemas/schema-binding.xjb) all xsds in servieoperations and types folder.

Is there any better way to configure this plugin then please tell me so I can correct it on my side. I am guessing you are the author of this plugin.

Thanks & Regards

Basit Mahmood Ahmed

解决方案

Current status of that issue, to spare others frustration and searching...

This issue shows up randomly and is caused by a bug in JAXB implementation. The issue was reported https://java.net/jira/browse/JAXB-687 however it is closed now, even though it is not fixed (see comment from suboptimal user posted on 16 Sep 2016).

这篇关于出现错误,在使用maven-jaxb2-plugin的整个编译过程中仅允许一个globalBindings定制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆