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

问题描述

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

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

用于生成实体的JDL

@H_404_6@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并成功运行,没有任何错误

@H_404_6@$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!

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

@H_404_6@ ██╗ ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗ ████████╗ ███████╗ ██║ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗ ██║ ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝ ██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ :: 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$0(AsyncSpringLiquibase.java:93) at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(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. 我不得不使用删除并重新安装节点模块
rm -rf node_modules 
npm install
  1. 在升级时,它询问了以下一个问题。我只单击了Enter,我猜它采用了默认选项
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