在Maven中使用Liquibase扩展

时间:2011-11-21 15:18:45

标签: maven liquibase

我正在尝试使用Liquibase Oracle extensions中的maven-liquibase-plugin,但我无法使其正常运行。我对命令行中的相同changeLog文件没有任何问题,但在Maven中我收到以下错误消息

SEVERE 21/11/11 14:49:liquibase: Error thrown as a SAXException: Unknown Liquibase extension: dropTrigger. Are you missing a jar from your classpath?

我正在使用的更改日志文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ora="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <changeSet author="PE1926" id="ONCHANGE" runOnChange="true">
    <ora:dropTrigger schemaName="" triggerName="TRIGGER_01"/>
    <rollback>
        <sqlFile path="latest/trg/TRIGGER_01.sql" endDelimiter="$"/>
    </rollback>
</changeSet>

这是一个pom.xml提取

[...]
<dependencies>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
    </dependency>   
    <dependency>
        <groupId>org.liquibase.ext</groupId>
        <artifactId>liquibase-oracle</artifactId>
        <version>1.2.0</version>
    </dependency>   
</dependencies>

<build>
    <plugins>       
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>2.0.3</version>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals><goal>status</goal></goals>
                </execution>
            </executions>
            <configuration>
                <changeLogFile>src/main/resources/update.xml</changeLogFile>    
                <propertyFile>${db-resources.dir}/liquibase.properties</propertyFile>
                <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                <verbose>true</verbose>
            </configuration>
        </plugin>
    </plugins>
</build>

我还尝试将liquibase-oracle添加为插件依赖项,但我收到了相同的错误消息。

这是从Maven使用Liquibase扩展的正确方法吗?我错过了什么吗?

2 个答案:

答案 0 :(得分:7)

将所有liquibase依赖项添加为插件依赖项

答案 1 :(得分:0)

我不需要添加任何其他依赖项 - 这是为我做的:

<pluginManagement>
  <plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>${version.liquibase}</version>
    <configuration>
      <propertyFileWillOverride>true</propertyFileWillOverride>
      <driver>oracle.jdbc.OracleDriver</driver>
      <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
      <changeLogFile>liquibase-master-changelog.xml</changeLogFile>
      <!-- ensure a liquibase.properties is available in each module that runs liquibase -->
      <propertyFile>liquibase.properties</propertyFile>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>org.liquibase.ext</groupId>
        <artifactId>liquibase-oracle</artifactId>
        <version>${version.liquibase.ora-ext}</version>
      </dependency>
    </dependencies>
    <executions>
      <execution>
        <phase>test-compile</phase>
        <goals>
          <goal>update</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</pluginManagement>