私のmaven
プロジェクトでは、私のdatetime
のすべてのエントリをXMLGregorianCalendar
の代わりにjava.util.date
として生成する必要があります。ご存知のように、デフォルトでXMLGregorianCalendar
が生成されます。外部バインディングファイル(XJB)を使用してXMLGregorianCalendarを日付に変更します
例としては、hereというプロジェクトがあります。
ここCustomersOrders.xsdで、あなたは、その属性ShippedDate
がタイプdateTime
である見ることができます。 java.util.date
にそのデータ型を変換するには
<xs:attribute name='ShippedDate' type='xs:dateTime' />
、私はドキュメントhereで提供アプローチを以下のよ。すなわちのように、外部結合ファイルを使用して:
Customer.xjb
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<globalBindings>
<javaType name="java.util.date" xmlType="xs:datetime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
printMethod="javax.xml.bind.DatatypeConverter.printDate"
/>
</globalBindings>
</bindings>
その後、私は次のようにpom.xml
でCustomer.xjb
ファイルをマッピングされた:
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- the package for the generated java classes -->
<generatePackage>com.dimitrisli.jaxb.producedClasses</generatePackage>
<!-- If the following not specified all xsd in resources are included -->
<schemaIncludes>
<include>sampleJaxb/CustomersOrders.xsd</include>
</schemaIncludes>
<!-- if you don't want old output -->
<removeOldOutput>true</removeOldOutput>
<!-- if you want verbosity -->
<!-- verbose>true</verbose -->
<xjbSources>
<xjbSource>sampleJaxb/Customers.xjb</xjbSource>
</xjbSources>
</configuration>
</execution>
</executions>
しかし、私はmvn clean install
を行うとき、私はよまだの相違を見ることができず、依然としてXMLGregorianCalendar
として生成されています。
私は何が欠けているのかをお勧めします。
あなたがorg.jvnet.jaxb2.maven2:maven-jaxb2-plugin
を使用している場合、あなたはbindingIncludes
代わりのxjbSources
を(それはorg.codehaus.mojo:jaxb2-maven-plugin
のためです)を使用する必要があります