我使用JDL studio创建文件时没有错误但是当我使用jhipster cli导入文件时出现以下错误:
Using JHipster version installed locally in current project's node_modules Executing jhipster:import-jdl ./thearthacker-jdl.jh Options: The jdl is being parsed. events.js:182 throw er; // Unhandled 'error' event ^ Error: ERROR! Error while parsing entities from JDL at Environment.error (E:\web_project\_PROJECT\thearthackers\node_modules\yeoman-environment\lib\environment.js:140:40) at constructor.error (E:\web_project\_PROJECT\thearthackers\node_modules\generator-jhipster\generators\generator-base.js:1686:18) at constructor.parseJDL (E:\web_project\_PROJECT\thearthackers\node_modules\generator-jhipster\generators\import-jdl\index.js:108:22) at Object. (E:\web_project\_PROJECT\thearthackers\node_modules\yeoman-generator\lib\index.js:417:23) at E:\web_project\_PROJECT\thearthackers\node_modules\run-async\index.js:25:25 at Promise () at E:\web_project\_PROJECT\thearthackers\node_modules\run-async\index.js:24:19 at E:\web_project\_PROJECT\thearthackers\node_modules\yeoman-generator\lib\index.js:418:9 at runCallback (timers.js:781:20) at tryOnImmediate (timers.js:743:5)
这是我的JDL文件:
entity Video {
name String required,
type String required,
url String required,
quality String,
description String required,
submissionDate ZonedDateTime required
}
entity Picture {
name String required minlength(3),
type String required,
url String required,
size String,
description String,
submissionDate ZonedDateTime required
}
entity Blog {
name String required minlength(3),
}
entity Entry {
title String required,
content String required,
date ZonedDateTime required
}
entity Tag {
name String required minlength(2)
}
relationship ManyToMany {
Entry{tag(name)} to Tag{entry}
}
relationship ManyToMany {
Picture{tag(name)} to Tag{Picture}
}
relationship ManyToMany {
Video{tag(name)} to Tag{Video}
}
relationship ManyToMany {
Blog{tag(name)} to Tag{Blog}
}
relationship ManyToMany {
User{tag(name)} to Tag{User}
}
relationship ManyToOne {
Video{video} to User
}
relationship ManyToOne {
Picture{video} to User
}
relationship ManyToOne {
Blog{video} to User
}
relationship ManyToOne {
Entry{video} to Blog
}
paginate Entry, Tag with infinite-scroll
dto * with mapstruct
任何想法?
感谢您的帮助。
答案 0 :(得分:5)
我刚刚尝试过您的JDL并收到此错误消息:
IllegalAssociationException: Relationships from User entity is not supported in the declaration between User and Tag.
请注意我正在使用当前的开发分支,因此我有一条您可能没有的错误消息(您没有提供您的版本号,但最近有所改进)。
这意味着你不能从User实体做关系,因为它不能被JDL修改 - 这是特定于User实体的。您可以找到更多信息on the relationships documentation。
有几种解决方案:您可以与用户建立一对一的关系,并拥有您通过JDL管理的另一个实体。或者您可以手动修改用户实体(有些人将其子类化并在子类上工作,以便不更改用户)。