运行更新时,我收到Liquibase异常。
Caused by: liquibase.exception.UnknownChangelogFormatException:
Cannot find parser that supports <?xml version="1.0" encoding="UTF-8" standalone="no"?>
我认为Liquibase默认支持xml解析,所以我不确定这里的情况。我在初始化课程时错过了配置吗?
private lazy val liquibase: Liquibase = {
val fsFO: ResourceAccessor = new FileSystemResourceAccessor
val clFO: ResourceAccessor = new ClassLoaderResourceAccessor
val contextClassLoader = Thread.currentThread().getContextClassLoader
val threadClFO: ResourceAccessor = new ClassLoaderResourceAccessor(contextClassLoader)
val database = DatabaseFactory.getInstance.findCorrectDatabaseImplementation(new JdbcConnection(connection))
new Liquibase(changeLog, new CompositeResourceAccessor(clFO, fsFO, threadClFO), database)
}
def update(): Unit = Try(liquibase.update(context)) match {
case Success(_) => log.info("LIQUIBASE FINISHED: Update change log")
case Failure(ex) => throw new Exception("LIQUIBASE FAILED: Update change log", ex)
}
变量 changelog 是使用`java.o.File
读取的 String val fileReader = new FileReader(file)
val characters = new Array[Char](file.length().toInt)
fileReader.read(characters)
new String(characters)
Master.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<changeSet author="author" id="1444318866725-1">
<createTable tableName="author">
<column name="id" type="INT">
<constraints nullable="false"/>
</column>
<column defaultValue="NULL::character varying" name="first_name" type="VARCHAR(255)"/>
<column defaultValue="NULL::character varying" name="last_name" type="VARCHAR(255)"/>
</createTable>
</changeSet>
<changeSet author="author" id="1444318866725-2">
<addPrimaryKey columnNames="id" constraintName="author_pkey" tableName="author"/>
</changeSet>
<changeSet author="author" id="add-column-gender">
<dropColumn tableName="author">
<column name="first_name"/>
</dropColumn>
<addColumn tableName="author">
<column name="gender" type="varchar(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>
答案 0 :(得分:4)
问题似乎是changeLog
变量不是String
,而是包含changelog文件的路径。