본문 바로가기

개발

Spring Boot + Maven 으로 Liquibase ValidationFailedException : liquibase check sums error any changes not postgresql

728x90

 

 

Spring Boot + Maven 으로 Liquibase 를 이용면서 간혹 어떤 변경을 하지 않았는데, 아래와 같이 liquibase check sum exception 이 발생하는 경우가 있다. 이런 상황은 개발 중이던 서버가 갑자기 종료 되면서 "databasechangelog" 가 정상적으로 반영되지 않아 발생하는 문제다.

 

[Excepiton Message]
nested exception is liquibase.exception.ValidationFailedException: Validation Failed: 4 change sets check sum   

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcess
or.java:595)                                                                                                                                                
... 114 common frames omitted                                                                                                                       
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [ml/jjeaby/DatabaseConfig.class]: Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Valida
tion Failed:                                                                                                                                                
4 change sets check sum                                                                                                                                
liquibase/init_configuration_attribute.xml:: 8:7f88e180ca434dee353d8
13cba521279 but is now: 8:fe3670503df0afce58f2376151e32813                                                                                                  
liquibase/init_menu.xml:: was: 8:1642456c5c29bcbcf4b12d09c4e6f00c but is now: 8:96d3907c82ca4fe5c20921893fae915d                                                                                                                                                 
liquibase/init_authority.xml:: was: 8:5a8654ae09c7de47841a6a0b47503729 but is now: 8:f5ff821aa6f33213a96aca07e50f1bdc                                                                                                                                  
liquibase/temp_message.xml:: was: 8:7258aa0bafe18d98c66a01c2007606ea but is now: 8:961a81a4da099582ff843c704d958489                                                                                                                                         
                                                                                                                                            
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1771)        
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)           
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)             
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)                                   
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)                       
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)                       

 

이 문제는 liquibase-maven-plugin 을 이용하면 해결이 가능하다.

 

 

1. pom.xml 에 liquibase-maven-plugin 설정 추가 

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <driver>org.postgresql.Driver</driver>
        <url>jdbc:postgresql://localhost:5432/jjeaby</url>
        <username>jjeaby</username>
        <password>jjeabypw</password>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>clearCheckSums</goal>
            </goals>
        </execution>
    </executions>
</plugin>

 

 

2. mvn liquibase:clearCheckSums 명령어 실행

mvn liquibase:clearCheckSums

 

[실행 결과]

[INFO] Clearing database change log checksums
[INFO] SELECT COUNT(*) FROM databasechangeloglock
[INFO] SELECT COUNT(*) FROM databasechangeloglock
[INFO] SELECT LOCKED FROM databasechangeloglock WHERE ID=1
[INFO] Successfully acquired change log lock
[INFO] SELECT MD5SUM FROM databasechangelog WHERE MD5SUM IS NOT NULL LIMIT 1
[INFO] UPDATE databasechangelog SET MD5SUM = NULL
[INFO] Successfully released change log lock
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.200 s
[INFO] Finished at: 2020-06-01T17:16:19+09:00
[INFO] ------------------------------------------------------------------------

 

 

 

이렇게 쉽게 해결이 가능하니, 멘붕에 빠지지 잘고 잘 찾아보좌~~~:)