jaxb转换xsd为java类时: 具有相同名称 "com.common.ab.Date" 的类/接口已在使用。请使用类定制设置来解决此冲突。
生成xsd的命令
java -jar trang.jar .\initerror.xml error.xsd
生成java类的命令
xjc -d . -p com.common.ab error.xsd
-d 生成文件的目录 -p 生成java类的包名
通过网上trang.jar生成的xsd文件用jaxb生成java类时报错.
原因: 生成的文件中有多个同类型type="date"引用
正确格式: 让生成的xsd引用date是用一下方式 ref="date"
做法: 本来只有一个date子节点的地方增加一个无用节点<dddd>sd</dddd>
完善: 把生成的java类中无用的节点删除即可
会生成错误xsd的xml文档:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="SPAUSD">
<submit>
<order orderCode="20191202654321">
<description>YOUR DESCRIPTION</description>
<amount value="2000" currencyCode="EUR" exponent="2"/>
<orderContent>
<![CDATA[]]>
</orderContent>
<paymentDetails>
<CARD-SSL>
<cardNumber>4444333322221111</cardNumber>
<expiryDate>
<date month="01" year="2020"/>
</expiryDate>
<cardHolderName>3DS_V2_CHALLENGE_IDENTIFIED</cardHolderName>
<cvc>123</cvc>
<cardAddress>
<address>
<address1>Worldpay</address1>
<address2>270-289 The Science Park</address2>
<address3>Milton Road</address3>
<postalCode>CB4 0WE</postalCode>
<city>Cambridge</city>
<countryCode>GB</countryCode>
</address>
</cardAddress>
</CARD-SSL>
<session shopperIPAddress="127.0.0.1" id="SESSION_ID"/> <!--Session id must be unique -->
</paymentDetails>
<shopper>
<shopperEmailAddress>[email protected]</shopperEmailAddress>
<browser>
<acceptHeader>text/html</acceptHeader>
<userAgentHeader>Mozilla/5.0 ...</userAgentHeader>
</browser>
</shopper>
<!-- Optional Risk Data -->
<riskData>
<authenticationRiskData authenticationMethod="localAccount">
<authenticationTimestamp><date second="01" minute="02" hour="03" dayOfMonth="01" month="06" year="2019"/></authenticationTimestamp>
</authenticationRiskData>
<shopperAccountRiskData
transactionsAttemptedLastDay="1"
transactionsAttemptedLastYear="100"
purchasesCompletedLastSixMonths="50"
addCardAttemptsLastDay="1"
previousSuspiciousActivity="true"
shippingNameMatchesAccountName="true"
shopperAccountAgeIndicator="lessThanThirtyDays"
shopperAccountChangeIndicator="lessThanThirtyDays"
shopperAccountPasswordChangeIndicator="noChange"
shopperAccountShippingAddressUsageIndicator="thisTransaction"
shopperAccountPaymentAccountIndicator="lessThanThirtyDays">
<shopperAccountCreationDate><date dayOfMonth="01" month="02" year="2003"/></shopperAccountCreationDate>
<shopperAccountModificationDate><date dayOfMonth="02" month="03" year="2004"/></shopperAccountModificationDate>
<shopperAccountPasswordChangeDate><date dayOfMonth="03" month="04" year="2005"/></shopperAccountPasswordChangeDate>
<shopperAccountShippingAddressFirstUseDate><date dayOfMonth="04" month="05" year="2006"/></shopperAccountShippingAddressFirstUseDate>
<shopperAccountPaymentAccountFirstUseDate><date dayOfMonth="05" month="06" year="2007"/></shopperAccountPaymentAccountFirstUseDate>
</shopperAccountRiskData>
<transactionRiskData
shippingMethod="shipToBillingAddress"
deliveryTimeframe="overnightShipping"
deliveryEmailAddress="[email protected]"
reorderingPreviousPurchases="true"
preOrderPurchase="false"
giftCardCount="1">
<transactionRiskDataGiftCardAmount><amount value="1" currencyCode="EUR" exponent="2"/></transactionRiskDataGiftCardAmount>
<transactionRiskDataPreOrderDate><date dayOfMonth="06" month="07" year="2008"/></transactionRiskDataPreOrderDate>
</transactionRiskData>
</riskData>
<!-- Additional 3DS data that you must provide to us -->
<additional3DSData
dfReferenceId="ddbc4809-4ad6-4143-a503-ac3c3c7647ea"
challengeWindowSize="390x400"
challengePreference="challengeMandated"/>
</order>
</submit>
</paymentService>