简体   繁体   English

从JDL文件jhipster解析实体时出错

[英]Error while parsing entities from JDL file jhipster

I create file with JDL studio without error but when I import the file with jhipster cli I have the following error: 我使用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)

and this is my JDL file: 这是我的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

any idea ? 任何想法 ?

thanks for help. 感谢帮助。

I just tried your JDL and had this error message: 我刚刚尝试了您的JDL并收到以下错误消息:

IllegalAssociationException: Relationships from User entity is not supported in the declaration between User and Tag.

Please note that I'm using the current development branch, so I have an error message that you probably don't have (you don't give your version number, but that was improved very recently). 请注意,我正在使用当前的开发分支,因此我收到一条您可能没有的错误消息(您没有提供您的版本号,但是最近进行了改进)。

What this means is that you can't do relationships from the User entity, as it can't be modified by the JDL - that's specific to the User entity. 这意味着您无法与User实体建立关系,因为它无法被JDL修改-这是特定于User实体的。 You can find more information on the relationships documentation . 您可以在关系文档中找到更多信息。

There are several solutions to this: you can do a one-to-one relationship to the User, and have another entity that you manage through the JDL. 有几种解决方案:您可以与用户建立一对一关系,并拥有另一个通过JDL管理的实体。 Or you can modify the User entity manually (some people sub-class it and work on the sub-class, in order not to change the User). 或者,您可以手动修改User实体(有些人将其子类化,然后使用该子类,以便不更改User)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM