我们正在使用Modelio创建实体图并将其导出为XMI文件。
一旦我们拥有XMI,我们就可以使用jhipster uml工具生成源代码。
由于我们在某些实体中需要一个日期字段,因此我们在Modelio中添加了一个名为DateTime的数据类型。目的是在Java类中生成org.joda.time.DateTime。
运行jhipster url.jhipster-uml test.xmi
时出现以下错误Parser detected: MODELIO.
The type 'DateTime' isn't supported by JHipster, exiting now.
Error
at Object.<anonymous> (/usr/local/lib/node_modules/jhipster-uml/lib/exceptions/invalid_type_exception.js:7:34)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
我们在这里缺少什么? 我想我们需要告诉Modelio在哪里/如何将DateTime类型映射到joda类。
以下是通过Modelio 3.4.1
导出的完整XMI文件<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:JavaExtensions="http:///schemas/JavaExtensions/_UVePsJdXEeWrwNWyJ1cDng/0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xsi:schemaLocation="http:///schemas/JavaExtensions/_UVePsJdXEeWrwNWyJ1cDng/0 JavaExtensions.profile.xmi#_UVnZp5dXEeWrwNWyJ1cDng">
<uml:Model xmi:id="_UVGcQJdXEeWrwNWyJ1cDng" name="test">
<eAnnotations xmi:id="_UVGcQZdXEeWrwNWyJ1cDng" source="Objing">
<contents xmi:type="uml:Property" xmi:id="_UVGcQpdXEeWrwNWyJ1cDng" name="exporterVersion">
<defaultValue xmi:type="uml:LiteralString" xmi:id="_UVGcQ5dXEeWrwNWyJ1cDng" value="3.0.0"/>
</contents>
</eAnnotations>
<packagedElement xmi:type="uml:Class" xmi:id="_UVGcRJdXEeWrwNWyJ1cDng" name="TestClass">
<ownedComment xmi:id="_UVGcRZdXEeWrwNWyJ1cDng">
<body><Enter note text here></body>
</ownedComment>
<ownedAttribute xmi:id="_UVGcRpdXEeWrwNWyJ1cDng" name="testAtt" visibility="public" type="_UVGcR5dXEeWrwNWyJ1cDng" isUnique="false"/>
</packagedElement>
<packagedElement xmi:type="uml:PrimitiveType" xmi:id="_UVGcR5dXEeWrwNWyJ1cDng" name="DateTime"/>
<profileApplication xmi:id="_UWtl0JdXEeWrwNWyJ1cDng">
<eAnnotations xmi:id="_UWvbAJdXEeWrwNWyJ1cDng" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href="JavaExtensions.profile.xmi#_UVnZp5dXEeWrwNWyJ1cDng"/>
</eAnnotations>
<appliedProfile href="JavaExtensions.profile.xmi#_UVnZoJdXEeWrwNWyJ1cDng"/>
</profileApplication>
</uml:Model>
<JavaExtensions:JavaDataType xmi:id="_UW1hoJdXEeWrwNWyJ1cDng" base_DataType="_UVGcR5dXEeWrwNWyJ1cDng" base_PrimitiveType="_UVGcR5dXEeWrwNWyJ1cDng"/>
</xmi:XMI>
答案 0 :(得分:0)
jhipster使用joda库将日期写入实体。我想你必须使用joda的LocalDate
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@JsonSerialize(using = CustomLocalDateSerializer.class)
@JsonDeserialize(using = ISO8601LocalDateDeserializer.class)
@Column(name = "fecha")
private LocalDate fecha;