JHipster jdl 导入实体生成器无法在实体之间创建关系

JHipster jdl import entity generator failing to create relationship between entities

我正在使用 JHipster JDL 生成实体。

信息!在当前项目的 node_modules 中使用本地安装的 JHipster 版本 6.10.1

用于生成实体的JDL

entity Products{
    name String required
    brand String required
    quantity String required
    messurement String
    description String
}

entity ProductTypes{
    productType String required
    description String
}

relationship ManyToOne{
    Products{productType} to ProductTypes
}

// Set pagination options
paginate all with pagination

// Use Data Transfert Objects (DTO)
dto * with mapstruct

// Set service options to all except few
service all with serviceImpl

// Set an angular suffix
// angularSuffix * with mySuffix

使用下面的命令 运行 JDL 和 运行 成功,没有任何错误

$jhipster import-jdl jdl/jhipster-jdl.jdl

Output Summary:

 DONE  Compiled successfully in 23047ms                                              4:15:42 PM

   489 modules
INFO! Congratulations, JHipster execution is complete!

现在尝试启动应用程序时,出现以下错误

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster   :: Running Spring Boot 2.2.7.RELEASE ::
:: https://www.jhipster.tech ::

2020-10-24 16:17:09.493  WARN 17105 --- [  restartedMain] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 5001 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).

***

2020-10-24 16:17:17.546 DEBUG 17105 --- [  restartedMain] c.m.l.config.LiquibaseConfiguration      : Configuring Liquibase
2020-10-24 16:17:17.551  WARN 17105 --- [lication-task-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Starting Liquibase asynchronously, your database might not be ready at startup!
2020-10-24 16:17:18.891 DEBUG 17105 --- [  restartedMain] c.m.l.security.jwt.TokenProvider         : Using a Base64-encoded JWT secret key
2020-10-24 16:17:20.312 ERROR 17105 --- [lication-task-1] liquibase.changelog.ChangeSet            : Change Set config/liquibase/changelog/20201008101647_added_entity_constraints_Products.xml::20201008101647-2::jhipster failed.  Error: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]
2020-10-24 16:17:20.320 ERROR 17105 --- [lication-task-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Liquibase could not start correctly, your database is NOT ready: Migration failed for change set config/liquibase/changelog/20201008101647_added_entity_constraints_Products.xml::20201008101647-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]

liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20201008101647_added_entity_constraints_Products.xml::20201008101647-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:646)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:83)
    at liquibase.Liquibase.update(Liquibase.java:202)
    at liquibase.Liquibase.update(Liquibase.java:179)
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:366)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:314)
    at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
    at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
    at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet[=12=](AsyncSpringLiquibase.java:93)
    at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable(ExceptionHandlingAsyncTaskExecutor.java:78)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: liquibase.exception.DatabaseException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:402)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:59)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:131)
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1276)
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1258)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:609)
    ... 13 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
    at org.h2.message.DbException.get(DbException.java:205)
    at org.h2.message.DbException.get(DbException.java:181)
    at org.h2.table.Table.getColumn(Table.java:703)
    at org.h2.table.IndexColumn.mapColumns(IndexColumn.java:115)
    at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:216)
    at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:78)
    at org.h2.command.CommandContainer.update(CommandContainer.java:198)
    at org.h2.command.Command.executeUpdate(Command.java:251)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:398)
    ... 18 common frames omitted

2020-10-24 16:17:20.750 DEBUG 17105 --- [  restartedMain] c.m.l.config.DatabaseConfiguration       : H2 database is available on port 18080
2020-10-24 16:17:31.364 DEBUG 17105 --- [  restartedMain] i.g.j.c.apidoc.SwaggerAutoConfiguration  : Starting Swagger
2020-10-24 16:17:31.372 DEBUG 17105 --- [  restartedMain] i.g.j.c.apidoc.SwaggerAutoConfiguration  : Started Swagger in 7 ms
2020-10-24 16:17:37.031  INFO 17105 --- [  restartedMain] com.mv.localshops.BaseapplicationApp     : Started BaseapplicationApp in 43.019 seconds (JVM running for 43.521)
2020-10-24 16:17:42.040  INFO 17105 --- [  restartedMain] com.mv.localshops.BaseapplicationApp     : 
----------------------------------------------------------
    Application 'baseapplication' is running! Access URLs:
    Local:      http://localhost:8080/
    External:   http://192.168.1.11:8080/
    Profile(s):     [dev, swagger]
----------------------------------------------------------

你能帮我理解为什么会抛出这个错误吗?我是否以正确的方式使用 JHipster 实体生成器?

感谢任何帮助。

将 JHipster 从 6.10.1 升级到 6.10.4 后问题得到解决

使用下面的命令进行升级,效果很好

jhipster upgrade

我遵循了两件事:

  1. 我不得不使用
  2. 删除并重新安装节点模块
rm -rf node_modules 
npm install
  1. 升级时问了下面一个问题。我只是点击进入,我猜它采用了默认选项
git rev-parse -q --abbrev-ref HEAD
master
? Unify blueprints configurations?

git rev-parse -q --abbrev-ref HEAD
master
? Unify blueprints configurations? Yes
     info Skipping config upgrade, config generated with jhipster version: 6.10.1
git rev-parse -q --verify jhipster_upgrade
git checkout --orphan jhipster_upgrade
Switched to a new branch 'jhipster_upgrade'
✔ Created branch jhipster_upgrade