다른 .xsd 파일이 있고 다른 패키지에서 Java 클래스를 생성하려고합니다. 내가 여기오류가 발생했습니다. eclipse에서 maven-jaxb2-plugin을 사용하는 동안 요소 바인딩의 네임 스페이스가 스키마 네임 스페이스에 있어야합니다.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.11.0</version>
<executions>
<execution>
<id>generate-messages</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<forceRegenerate>true</forceRegenerate>
<generateDirectory>${basedir}/src/main/java</generateDirectory>
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/resources/bindings</directory>
<includes>
<include>lmsApiBinding.xml</include>
</includes>
</fileset>
</schema>
</schemas>
</configuration>
</plugin>
을 다음과 같은 받는다는 maven-jaxb2-plugin
를 구성하는 것은 여기 내 파일
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
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 generateElementProperty="false">
<xjc:serializable uid="1" />
</jaxb:globalBindings>
<jaxb:bindings schemaLocation="/src/main/webapp/schemas/lmsapi/serviceoperations/CustomerServiceOperations.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="abc.customer" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="/src/main/webapp/schemas/lmsapi/serviceoperations/EnrollmentServiceOperations.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="def.enrollment" />
</jaxb:schemaBindings>
</jaxb:bindings>
....
</jaxb:bindings>
내 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:sequence>
<xsd:element name="Customers" type="cust:Customers" minOccurs="1" maxOccurs="1" nillable="false" />
</xsd:sequence>
<xsd:attribute name="key" type="xsd:string" use="required" />
<xsd:attribute name="ResellerId" type="xsd:nonNegativeInteger" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="AddCustomerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RegisterCustomers" type="cust:RegisterCustomers" minOccurs="0" maxOccurs="1" nillable="false" />
</xsd:sequence>
<xsd:attribute name="transactionResult" type="tr:TransactionResultType" use="required"/>
<xsd:attribute name="transactionResultMessage" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
입니다하지만 내 .pom
파일을 클릭하고 내가 할 그런 Run As --> maven Generate Sources
을 선택하면 다음과 같은 오류가 발생했습니다.
org.xml.sax.SAXParseException; systemId: file:/D:/Basit/eclipse-jee-luna/workspace/lms-api-1/src/main/resources/bindings/lmsApiBinding.xml; lineNumber: 10; columnNumber: 19; s4s-elt-schema-ns: The namespace of element 'bindings' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
...
org.xml.sax.SAXParseException; systemId: file:/D:/Basit/eclipse-jee-luna/workspace/lms-api-1/src/main/resources/bindings/lmsApiBinding.xml; lineNumber: 10; columnNumber: 19; s4s-elt-invalid: Element 'bindings' is not a valid element in a schema document.
...
org.xml.sax.SAXParseException; systemId: file:/D:/Basit/eclipse-jee-luna/workspace/lms-api-1/src/main/resources/bindings/lmsApiBinding.xml; lineNumber: 10; columnNumber: 19; schema_reference.4: Failed to read schema document 'file:/D:/Basit/eclipse-jee-luna/workspace/lms-api-1/src/main/resources/bindings/lmsApiBinding.xml', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
왜 이러한 오류가 발생합니까? 내가 뭘 잘못하고 있니?
감사
------ 편집
---- code--안녕, 감사 작업
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/webapp/schemas/lmsapi</directory>
<includes>
<include>/serviceoperations/CustomerServiceOperations.xsd</include>
<include>/serviceoperations/EnrollmentServiceOperations.xsd</include>
<include>/serviceoperations/OrgGroupServiceOperations.xsd</include>
...
<include>/types/Address.xsd</include>
<include>/types/Course.xsd</include>
<include>/types/Customer.xsd</include>
....
<include>/types/UserGroup.xsd</include>
<include>/types/Vu360User.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
--Final. 마침내 효과를 얻었습니다. 여기 내 파일 여기 LmsApiServiceOperations.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://com/softech/vu360/lms/webservice/message/lmsapi/serviceoperations"
xmlns="http://com/softech/vu360/lms/webservice/message/lmsapi/serviceoperations"
elementFormDefault="qualified">
<xsd:import namespace="http://trainingplan.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="TrainingPlanServiceOperations.xsd"/>
<xsd:import namespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="CustomerServiceOperations.xsd"/>
<xsd:import namespace="http://user.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="UserServiceOperations.xsd"/>
<xsd:import namespace="http://enrollment.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="EnrollmentServiceOperations.xsd"/>
<xsd:import namespace="http://securityroles.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="SecurityRoleServiceOperations.xsd"/>
<xsd:import namespace="http://orggroup.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="OrgGroupServiceOperations.xsd"/>
<xsd:import namespace="http://usergroup.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="UserGroupServiceOperations.xsd"/>
</xsd:schema>
는
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.11.0</version>
<executions>
<execution>
<id>generate-messages</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/main/resources/bindings</bindingDirectory>
<bindingIncludes>
<bindingInclude>lmsApiBinding.xml</bindingInclude>
</bindingIncludes>
<generateDirectory>${basedir}/src/main/java/</generateDirectory>
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/webapp/schemas/lmsapi/</directory>
<includes>
<include>serviceoperations/LmsApiServiceOperations.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
<strict>true</strict>
<extension>true</extension>
<verbose>true</verbose>
<forceRegenerate>true</forceRegenerate>
</configuration>
</execution>
</executions>
</plugin>
이 또한 내 lmsApiBinding.xml 파일은 이제
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
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 generateElementProperty="false">
<xjc:serializable uid="1" />
</jaxb:globalBindings>
</jaxb:bindings>
포함
플러그인 구성입니다 내가<jaxb:globalBindings generateElementProperty="false">
<xjc:serializable uid="1" />
</jaxb:globalBindings>
<jaxb:bindings schemaLocation="CustomerServiceOperations.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.softech.vu360.lms.webservice.message.lmsapi.serviceoperations.customer" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="/schemas/lmsapi/serviceoperations/EnrollmentServiceOperations.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.softech.vu360.lms.webservice.message.lmsapi.serviceoperations.enrollment" />
</jaxb:schemaBindings>
</jaxb:bindings>
같은 것을 사용하는 경우 때문에 그런 다음 Maven -> 소스 생성을 선택하십시오. 그런 다음 다음 오류가 발생합니다.
com.sun.istack.SAXParseException2; systemId: file:/D:/Basit/eclipse-jee-luna/workspace/360Training/lms-api-1/src/main/resources/bindings/lmsApiBinding.xml; lineNumber: 17; columnNumber: 86; "file:/D:/Basit/eclipse-jee-luna/workspace/360Training/lms-api-1/src/main/resources/bindings/CustomerServiceOperations.xsd" is not a part of this compilation. Is this a mistake for "file:/D:/Basit/eclipse-jee-luna/workspace/360Training/lms-api-1/src/main/resources/bindings/lmsApiBinding.xml"?
다른 패키지에 클래스를 생성하려고하기 때문에 바인딩 파일을 사용하고있었습니다. 하지만 그것은 targetnamespace에서 패키지 이름을 생성하는 것 같습니다. 내가 신고 한대로 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:schema>
소스를 생성 한 후. 그것은 자동으로 패키지에 com.softech.vu360.lms.webservice.message.lmsapi.serviceoperations.customer
감사
대신 serviceoperations/*. xsd'을 사용해보세요. – lexicore