Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Liquibase尝试应用所有变更集,即使数据库存在_Java_Mysql_Spring_Liquibase - Fatal编程技术网

Java Liquibase尝试应用所有变更集,即使数据库存在

Java Liquibase尝试应用所有变更集,即使数据库存在,java,mysql,spring,liquibase,Java,Mysql,Spring,Liquibase,我正在使用springliquibase执行登台数据库上需要的任何迁移 applicationContext.xml如下所示 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

我正在使用
springliquibase
执行登台数据库上需要的任何迁移

applicationContext.xml
如下所示

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="com.yahoo.comma"/>
    <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
        <property name="dataSource" ref="dataSource"/>
        <property name="changeLog" value="classpath:liquibase/changelog.xml"/>
        <property name="defaultSchema" value="pryme_dev"/>
    </bean>
</beans>
问题
-当数据库已经填充并且数据库有
DATABASECHANGELOG
文件存在时,为什么要应用所有更改集?
-我如何解决这个问题


感谢

问题通常是因为每个变更集的唯一标识符的一部分是变更日志文件的路径。它现在看起来像是“liquibase/2014/1-1.xml”


如果运行
select*from databasechangelog,其中id='05192014.1525'
数据库中已有的路径是什么?

只需添加新的更直接的信息,说明问题发生的原因

Liquibase使用DATABASECHANGELOG表跟踪已运行的变更集

该表将每个变更集作为一行进行跟踪,由存储变更日志文件路径的“id”、“author”和“filename”列的组合标识

请注意,“文件名”列存储更改日志的路径。这可能是绝对路径,也可能是相对路径,具体取决于changelog传递给Liquibase的方式为了获得最佳结果,它应该是一条相对路径


如果像迁移一样移动数据库,并且文件名列包含完整路径,Liquibase可能无法从DATABASECHANGELOG表中识别变更集。

只需添加有关对我有效的信息

Liquibase正在查找与JAR相关的路径“BOOT-INF/classes/db/changelog/sql/”,但问题是在db
databasechangelog
filename
列中有“db/changelog/sql/”这个路径

因此,我在我的数据库上运行以下查询来解决我的问题

update customer.databasechangelog set filename=replace(文件名'db/changelog/sql/','BOOT-INF/classes/db/changelog/sql/')


由于我是新来的液化者,我不确定这种方法是否正确,但它确实解决了我的问题

在我的例子中,我需要为Liquibase指定默认模式,添加spring属性:

spring.liquibase.default-schema=public

查看堆栈跟踪,这不是liquibase的太多内容,而是您设置测试用例的方式。在我的例子中,
DATABASECHANGELOG
表本身是空的。然而,其他的桌子都很得体
spring.liquibase.default-schema=public