1

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

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

我想传入“changesToApply”,见http://www.liquibase.org/manual/maven_updatesql

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

mvn liquibase:updateSQL -DchangesToApply=2
4

4 回答 4

6

简短的回答:

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}

这就是你应该使用的

于 2012-08-21T22:06:12.210 回答
1

来自Maven Liquibase 插件手册

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

[...]
<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>
[...]
于 2012-01-04T06:50:00.013 回答
1

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

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

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

于 2012-05-01T14:02:22.060 回答
1

对于版本 3.5.5 应该<executions>如下所示:

<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>
于 2018-04-04T09:38:23.383 回答