如果计算机未连接到互联网,Liquibase 将失败

Alb*_*nov 5 liquibase

当我尝试启动 Liquibase(使用 Karaf)时,出现以下错误

'无法读取架构文档http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xml,原因 1) 找不到文档;2) 无法读取文件;3) 文档的根元素不是 '

如果计算机连接到互联网,则不会重现此错误。

a_h*_*ame 7

我最近自己偶然发现了这个。

你需要改变这个:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
Run Code Online (Sandbox Code Playgroud)

并删除 XSD 的 URL:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog-3.0.xsd">
Run Code Online (Sandbox Code Playgroud)

注之间的空间http://www.liquibase.org/xml/ns/dbchangelogdbchangelog-3.0.xsd。第一个元素是命名空间的 URI,第二个元素指向实际的 XSD 文件。如果不包含 URL,XML 解析器将尝试使用本地文件。

然后将实际的 XSD 放入更改日志 XML 所在的同一目录中。

您当然需要从可以访问互联网的计算机下载它,例如使用:

wget http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
Run Code Online (Sandbox Code Playgroud)

或者简单地用浏览器打开 URL 然后保存文件。

请注意,您还需要.xsd为架构位置指定一个文件,而不是一个.xml(如问题所示)。