New authority Jhipster



我遵循了文章中的说明https://www.jhipster.tech/tips/025_tip_create_new_authority.html我添加了一个新的权威";ROLE_CLIENT";之后,我重新启动了我的项目,出现了一个错误:

2021-07-13 00:22:46.592  WARN 3596 --- [  restartedMain] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2021-07-13 00:22:46.806 ERROR 3596 --- [ gateway-task-1] t.j.c.liquibase.AsyncSpringLiquibase     : Liquibase could not start correctly, your database is NOT ready: Validation Failed:
1 change sets check sum
config/liquibase/changelog/00000000000000_initial_schema.xml::00000000000001::jhipster was: 8:06225dfc05215e6b13d8a4febd3fd90f but is now: 8:2272077bd3e9baf389312f0e018e5795

liquibase.exception.ValidationFailedException: Validation Failed:
1 change sets check sum
config/liquibase/changelog/00000000000000_initial_schema.xml::00000000000001::jhipster was: 8:06225dfc05215e6b13d8a4febd3fd90f but is now: 8:2272077bd3e9baf389312f0e018e5795
at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:299)
at liquibase.Liquibase.lambda$update$1(Liquibase.java:237)
at liquibase.Scope.lambda$child$0(Scope.java:160)
at liquibase.Scope.child(Scope.java:169)
at liquibase.Scope.child(Scope.java:159)
at liquibase.Scope.child(Scope.java:138)
at liquibase.Liquibase.runInScope(Liquibase.java:2370)
at liquibase.Liquibase.update(Liquibase.java:217)
at liquibase.Liquibase.update(Liquibase.java:203)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:321)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:275)
at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
at tech.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
at tech.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:93)
at tech.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:78)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

顺便说一下,我使用的是微服务架构和JWT身份验证。

这很正常:Liquibase变更集应该是不可变的。

这就是为什么Liquibase在数据库变更日志表中的每个变更集条目中记录md5校验和,以检测当前变更日志中的内容与实际针对数据库运行的内容之间的差异。

当您修改authority.csv时,变更集的校验和发生了更改,Liquibase正确地抱怨了。

因此,您有3种替代解决方案:

  1. 创建一个单独的变更集,仅插入您的新权限(生产中的首选方式(
  2. 清除变更集中的校验和列。使用类似DBeaver的数据库客户端连接到数据库,并在DATABASECHANGELOG表中删除变更日志行的MD5SUM列。看看https://docs.liquibase.com/concepts/basic/databasechangelog-table.html
  3. 删除数据库以从头开始,如果您不关心自己的数据,这可能适用于开发数据库

最终建议:从官方文档以及JHipster文档了解更多关于Liquibase的信息

最新更新