有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在Jhipster中创建新实体后,不会在现有数据库中创建表

我在jhipster应用程序中有两个实体,在数据库中分别有两个表。现在,我已经使用jhipster entity命令在jhipster中添加了新的实体,但在运行应用程序之后,并没有在数据库中创建新的实体表。我已经尝试了所有的方法,但没有任何效果,所以我删除了现有的数据库(进行了备份),并在运行应用程序后创建了一个新的数据库

有谁能给我这个奇怪问题的解决方案吗。请查找以下实体。json文件

{ "fluentMethods": true, "clientRootFolder": "", "relationships": [ { "relationshipName": "userId", "otherEntityName": "user", "relationshipType": "many-to-one", "otherEntityField": "login", "ownerSide": true, "otherEntityRelationshipName": "emailStats" } ], "fields": [ { "fieldName": "unDeliverable", "fieldType": "Integer" }, { "fieldName": "autoReply", "fieldType": "Integer" }, { "fieldName": "deliveryFailed", "fieldType": "Integer" }, { "fieldName": "normal", "fieldType": "Integer" }, { "fieldName": "mailReceivedDate", "fieldType": "LocalDate" } ], "changelogDate": "20181030122031", "dto": "mapstruct", "searchEngine": false, "service": "serviceImpl", "entityTableName": "email_stats", "jpaMetamodelFiltering": true, "pagination": "pagination" }

共 (5) 个答案

  1. # 1 楼答案

    • 在项目中查找src/main/resources/config/liquibase/changelog/20211215051157_added_entity_NewEntity.xml文件
    • 复制文件名
    • 打开src/main/resources/config/liquibase/master.xml
    • 为添加的新实体进行如下手动输入(如果没有输入)
    <include file="config/liquibase/changelog/20211215051157_added_entity_NewEntity.xml" relativeToChangelogFile="false"/>
    
    • 运行应用程序。 这解决了我没有为新创建的实体创建相应表的问题
  2. # 3 楼答案

    你能在'src/main/resources/config/liquibase/changelog'下找到新的变更集xml文件吗? 如果是,只需检查它是否也在master中。xml

    删除现有数据库时,我通常使用以下命令'/mvnw liquibase:dropAll“and”/mvnw清洁'

    希望你能尽快修好

  3. # 4 楼答案

    我也有同样的问题,试试这个简单的解决方法

    将数据库重命名为其他名称,然后创建一个与应用程序-dev.yml或application-prod.yml中提供的名称相同的新数据库/mvnw

  4. # 5 楼答案

    运行命令./mvnw clean./gradlew clean将修复dev环境中的问题,然后再次运行./mvnw