Xml 多模块maven项目下的Jibx:
因为我没有足够的声誉来评论/回答。。。我需要在这里问一下 在我的项目中尝试使用JiBX一直令人沮丧。我有以下配置: Maven多模块项目:Xml 多模块maven项目下的Jibx:,xml,maven,xsd,jibx,Xml,Maven,Xsd,Jibx,因为我没有足够的声誉来评论/回答。。。我需要在这里问一下 在我的项目中尝试使用JiBX一直令人沮丧。我有以下配置: Maven多模块项目: parent-project +—— model-project This project will have the common domain objects defined on XSD files +—— message-project This project will contain the Webservice Request/
parent-project
+—— model-project This project will have the common domain objects defined on XSD files
+—— message-project This project will contain the Webservice Request/Response definitions on XSD and logic
+—— backend-project
+—— frontend-project
问题是:
关于模型项目,我假设:person.xsd是
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="http://www.myexample.com/schemas/app/person"
xmlns:per=“http://www.myexample.com/schemas/app/person">
<xsd:complexType name=“person">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name=“id" type="xsd:long" minOccurs="0" />
<xsd:element name=“firstName" type=“xsd:string" minOccurs="0" />
<xsd:element name=“lastName" type="xsd:string" minOccurs="0" />
<xsd:element name=“dob" type="xsd:dateTime" minOccurs="0" />
<xsd:element name=“age" type="xsd:int" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
在message project下,我们可以这样说:personService.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified”
xmlns:per=“http://www.myexample.com/schemas/app/personService"
targetNamespace="http://www.myexample.com/schemas/app/personService">
<xs:import namespace="http://www.myexample.com/schemas/app/personService" />
<xsd:complexType name=“getPersonRequest">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name=“id" type="xsd:long" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=“getPersonResponse">
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name=“person” type=“per:person” minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
最后,我能够使用JiBX定制和maven复制文件生成java源代码,其中包含对模块包的所需引用。。。当从XSD和fomr XSD生成代码时,如何可能引用在不同java包中生成代码的其他XSD,假设我的XSD在com.example.myapp.code中生成代码,我引用了另一个XSD,它在org.otherexample.theirapp.theircode中生成代码binding.xml属性包是空的,JiBX_bindingFactory类位于类路径的根。。。。。。因此,JiBX_bindingFactory没有包,但是JiBX的蹩脚spring框架封送器不接受null或空包,如果我用空值配置targetPackage属性,它会创建对.JiBX_bindingFactory的引用,但如果我使用null定义(不声明targetPackage)它将引发异常,因为我必须使用targetClass或targetPackage。但是targetClass只接受一个类,因此这意味着我需要为我想要封送/解封的每个类创建封送器引用