解决jhipster修改jdl生成的实体类报错:liquibase.exception.ValidationFailedException: Validation Failed
作者:木梨16
jhipster修改jdl生成的实体类报错
使用jhipster创建一个实体类之后,发现实体类不满足业务需求,需要修改:
如果是使用jdl创建的,那么我们只需要在原先的.jh文件中修改实体类内容,然后在项目根目录下执行命令:
jhipster import-jdl my_file1.jh
启动项目时发现会报错
报错信息
1 change sets check sum
config/liquibase/changelog/20190321053210_added_entity_Author.xml::20190321053210-1::jhipster was: 7:5a71ff93afda44eb57cf5111d94d4e2a but is now: 7:4f35ce5457b0fb6942f2f418533775c6
liquibase.exception.ValidationFailedException: Validation Failed:
1 change sets check sum
config/liquibase/changelog/20190321053210_added_entity_Author.xml::20190321053210-1::jhipster was: 7:5a71ff93afda44eb57cf5111d94d4e2a but is now: 7:4f35ce5457b0fb6942f2f418533775c6at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:266)
at liquibase.Liquibase.update(Liquibase.java:210)
at liquibase.Liquibase.update(Liquibase.java:192)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:431)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:388)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:103)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:83)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase$$Lambda$517/264907848.run(Unknown Source)
at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:68)
at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor$$Lambda$518/1505357671.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
解决方法(有两种)
1.如果数据库中还没有数据,可以直接将数据库中表全部删除,然后重新启动项目,jhipster会自动在数据库中再次生成一遍表结构
2.但有时候我们没办法将数据库中的表全部删除,
那只有用第二种方法了:在数据库中手动修改我们在实体类中修改的内容,修改完后,执行sql语句:
UPDATE DATABASECHANGELOG SET MD5SUM = 'your MD5SUM'
your MD5SUM 是可以在报错信息中找到的,就是第一行报错信息中的but is now:后面的值,我这里是:7:4f35ce5457b0fb6942f2f418533775c6
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。