如何设置液基类路径 [英] How to set liquibase classpath

查看:12
本文介绍了如何设置液基类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个JHipster项目。我希望手动运行Liquid Base变更集。默认情况下,变更集包含在类路径中。变更日志位于src/main/resources/config/liquibase/master.xml中,变更集位于src/main/resources/config/liquibase/changelog中。

<?xml version="1.0" encoding="utf-8"?>
<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.5.xsd">

    <include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
    <!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
    <!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
</databaseChangeLog>

运行mvn liquibase:update时,我收到一个错误,因为变更集不在类路径中,即使文件存在:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project playground: Error setting up or running Liquibase: liquibase.exception.SetupException: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist -> [Help 1]

所以我尝试通过设置类路径从命令行运行。

liquibase --classpath=src/main/resources --classpath=postgresql-42.1.3.jar 
--url=jdbc:postgresql://localhost:5432/playground 
--driver=org.postgresql.Driver 
--changeLogFile=src/main/resources/config/liquibase/master.xml 
--username playground --password=***** update

返回相同错误:Unexpected error running Liquibase: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist

解决方法是删除Include部分中的引用classpath:,但我希望避免在使用jhipster entityjhipster import-jdl时,每次jhister添加变更集时都编辑文件。

推荐答案

解决方案是在运行Liqubase命令之前运行mvn process-resources,这样src/main/resources下的文件将位于target/classes文件夹中。然后删除https://github.com/jhipster/generator-jhipster/pull/6121

中所述的classpath:部分

这篇关于如何设置液基类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆