【flyway】Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' def


報錯如下:

"2018-03-20 12:58:09.585  WARN 18026 — [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed: Migration checksum mismatch for migration version 1.3
-> Applied to database : -1338247141
-> Resolved locally    : 47067383"

解決方法:

原理:flyway是java 的sql migration庫 如果檢查resources/db/migrations/*.sql里邊已經遷移過的sql文件 checksum有變動 就會報錯

啟動之前將數據庫刪除 然后創建一個新的數據庫,這樣在啟動之后會自動創建數據庫中的表,保持一致 就不會報錯了

 

 

======================================================================

 

 

使用flyway進行數據庫字端更改【數據庫遷移】過程中 ,項目啟動出現這樣的問題 

問題解析:

這里的將這個數據庫的字端 由字符串類型更改為整形過程中出現問題   ,是因為flyway要去做字端類型更改的時候更改失敗,是因為這個字端已經在本地自己更改過了,flyway再去更改發現這個字端已經是int類型的,所以沒辦法再將這個字端由字符串類型更改為int類型了

 

解決方法:

1.如果本地數據庫沒有特別的數據,可以將本地的數據庫刪除,新建同名的數據庫 重啟服務即可

2.如果是服務器端的數據庫 不能刪除數據庫  那可以先在本地進行第一步的操作  然后 將flyway默認數據表中的數據 插入到數據庫對應表中 重啟即可 ,例如 本地數據庫中數據表如下

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in 整合spring與mybatis(Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'services' de) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDaoImpl' defined in file 開發Spring過程中幾個常見異常(二):Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'a' define 警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: mybatis Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'homeControll Spring AOP:Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'advertiseRestControll org.springframework.web.context.support.XmlWebApplicationContext.refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreatio SpringBoot 報 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapImportSelectorConfiguration': Initialization of bean failed;
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM