How to run Liquibase on jar execution using Maven?

问题描述 投票:0回答:0

我有一个带有 Liquibase 的 Maven 项目,我想通过执行 jar 文件来运行它。目前,我只能使用 Liquibase Maven 插件的版本 3.10.3 使其在构建阶段工作。我尝试使用较新版本的插件,但无法正常工作。

这是我当前的 pom.xml 文件:

<project>
  <!-- project details -->

  <properties>
    <liquibase.propertyFile>${project.basedir}/src/main/resources/liquibase.properties</liquibase.propertyFile>
  </properties>

  <dependencies>
    <!-- dependencies -->
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <!-- assembly plugin details -->
      </plugin>
      <plugin>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-maven-plugin</artifactId>
        <version>3.10.3</version>
        <configuration>
          <propertyFile>${liquibase.propertyFile}</propertyFile>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>update</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>3.1.2</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

当我执行 jar 文件而不是在构建阶段时,如何让 Liquibase 工作?有没有办法让它与更新版本的 Liquibase Maven 插件一起使用?

我相信它可以使用 exec-maven-plugin 来完成,但到目前为止我还没有能够做到。

提前感谢您的帮助!

liquibase maven-plugin exec-maven-plugin
© www.soinside.com 2019 - 2024. All rights reserved.