在特定的变更集上运行 mvn liquibase:updateSQL

发布于 2024-11-06 16:13:54 字数 357 浏览 2 评论 0原文

经验丰富的 Maven 用户可能可以在这里帮助我:

当将 liquibase 作为 Maven 目标运行时,如何将“可选参数”传递给 liquibase?

我想传递“changesToApply”,请参阅http://www.liquibase.org/manual/maven_updatesql

但是语法是什么? 类似这样,但不完全是:

mvn liquibase:updateSQL -DchangesToApply=2

Somebody who's a more seasoned maven user can probably help me out here:

how do I pass in "optional parameters" to liquibase when running it as a maven goal?

I want to pass in "changesToApply", see http://www.liquibase.org/manual/maven_updatesql

But what's the syntax?
Something like this, but not quite:

mvn liquibase:updateSQL -DchangesToApply=2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

醉酒的小男人 2024-11-13 16:13:54

简短回答:

mvn liquibase:updateSQL -Dliquibase.changesToApply=2

详细回答

转到您感兴趣的参数并查找其表达式。
http://www.liquibase.org/manual/maven_updatesql#changesToApply

查找

changesToApply:

The number of changes to apply to the database. By default this value is 0, which will result in all changes (not already applied to the database) being applied.
Type: int
Required: No
Expression: ${liquibase.changesToApply}
Default: 0

从此 ,你可以看到表达式是 ${liquibase.changesToApply}

Expression: ${liquibase.changesToApply}

这就是你应该使用的

Short answer:

mvn liquibase:updateSQL -Dliquibase.changesToApply=2

Long answer

Go to the parameter you're interested and look for it's expression.
http://www.liquibase.org/manual/maven_updatesql#changesToApply

Look for

changesToApply:

The number of changes to apply to the database. By default this value is 0, which will result in all changes (not already applied to the database) being applied.
Type: int
Required: No
Expression: ${liquibase.changesToApply}
Default: 0

From this, you can see the expression is ${liquibase.changesToApply}

Expression: ${liquibase.changesToApply}

That's what you should use

人生戏 2024-11-13 16:13:54

来自 Maven Liquibase 插件手册

执行Maven Liquibase插件的所有参数也可以
在插件的 部分中指定。下面是一个例子:

[...]
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>2.0.1</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <configuration>
        <changeLogFile>src/main/resources/org/liquiabse/business_table.xml</changeLogFile>
        <driver>oracle.jdbc.driver.OracleDriver</driver>
        <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
        <username>liquibaseTest</username>
        <password>pass</password>
      </configuration>
      <goals>
        <goal>update</goal>
      </goals>
    </execution>
  </executions>
</plugin>
[...]

From Maven Liquibase plugin manual

All the parameters for executing the Maven Liquibase plugin can also
be specified in <configuration> section of the plugin. Below is an example of this:

[...]
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>2.0.1</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <configuration>
        <changeLogFile>src/main/resources/org/liquiabse/business_table.xml</changeLogFile>
        <driver>oracle.jdbc.driver.OracleDriver</driver>
        <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
        <username>liquibaseTest</username>
        <password>pass</password>
      </configuration>
      <goals>
        <goal>update</goal>
      </goals>
    </execution>
  </executions>
</plugin>
[...]
み青杉依旧 2024-11-13 16:13:54

我是这样做的:
mvn liquibase:updateSQL -P mysql -DskipTests -Dliquibase.changeLogFile=create.xml

其中我的更改日志文件是“create.xml”
和“mysql”是一个预先配置的配置文件,用于填充我的数据库属性文件。

确保更改日志文件未硬编码在 liquibase.properties 文件中
确保重建模块,因为 Maven 目标将使用模块的 target/classes 目录中的 liquibase.properties

Here is how I do it:
mvn liquibase:updateSQL -P mysql -DskipTests -Dliquibase.changeLogFile=create.xml

where my change log file is "create.xml"
and "mysql" a pre-configured profile to populate my database properties file.

make sure though that the change log file is not hard coded in the liquibase.properties file
and make sure that you rebuild the module because the maven goal will use the liquibase.properties in the target/classes directory of the module

爱给你人给你 2024-11-13 16:13:54

对于版本 3.5.5 应该在 之外,如下所示:

<plugin>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-maven-plugin</artifactId>
      <version>3.0.5</version>
      <configuration>
        <changeLogFile>src/main/resources/org/liquibase/business_table.xml</changeLogFile>
          <driver>oracle.jdbc.driver.OracleDriver</driver>
          <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
          <username>liquibaseTest</username>
          <password>pass</password>
        </configuration>
      <executions>
        <execution>
          <phase>process-resources</phase>
          <goals>
            <goal>update</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

For the version 3.5.5 should go outside <executions> like below:

<plugin>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-maven-plugin</artifactId>
      <version>3.0.5</version>
      <configuration>
        <changeLogFile>src/main/resources/org/liquibase/business_table.xml</changeLogFile>
          <driver>oracle.jdbc.driver.OracleDriver</driver>
          <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
          <username>liquibaseTest</username>
          <password>pass</password>
        </configuration>
      <executions>
        <execution>
          <phase>process-resources</phase>
          <goals>
            <goal>update</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文