Liquibase:找不到基本路径' src / main / resources / com / example / database / changelog / v000 / master.xml'

时间:2015-04-29 06:12:56

标签: database maven liquibase

我正在尝试使用maven pluging构建liquibase项目,但是使用relativeFile路径遇到一些问题,我试图接近为liquibase maven项目定义的最佳实践。当我运行mvn liquibase:update时,我得到"无法找到基本路径"。

src/
`-- main
    |-- java
    `-- resources
        |-- changelog-1.0.0.xml
        |-- changelog-1.1.0.xml
        |-- changelog-install.xml
        |-- com
        |   `-- obolus
        |       `-- database
        |           `-- changelog
        |               |-- v000
        |               |   |-- cst
        |               |   |   |-- entity_extra_data.xml
        |               |   |   `-- entity.xml
        |               |   |-- master.xml
        |               |   `-- tab
        |               |       |-- company.xml
        |               |       |-- entity_extra_data.xml
        |               |       |-- entity.xml
        |               |       `-- anothertable.xml
        |               `-- v001
        |                   |-- master.xml
        |                   `-- tab
        |                       `-- sample.xml
        |-- lib
        |   |-- ojdbc6-11.2.0.3.jar
        `-- liquibase.properties

我的pom.xml的内容

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.obolus</groupId>
    <artifactId>database</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase.maven.plugin}</version>
                <configuration>
                    <changeLogFile>src/main/resources/changelog-install.xml</changeLogFile>
                    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                    <logging>${logLevel}</logging>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>status</goal>
                        </goals>
                    </execution>
                </executions>            
            </plugin>
        </plugins>
        <!-- resource filtering -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>${ojdbc.driver.version}</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <ojdbc.driver.version>11.2.0.3</ojdbc.driver.version>
        <liquibase.maven.plugin>3.3.2</liquibase.maven.plugin>
    <logLevel>severe</logLevel>
    </properties>
</project>

当我运行liquibase:update时,我收到以下错误

DEBUG 4/29/15 4:02 PM: liquibase: Using file opener for includeAll: liquibase.resource.CompositeResourceAccessor(org.liquibase.maven.plugins.MavenResourceAccessor(file:/home/www-data/workspace/database/target/classes/,file:/home/www-data/workspace/database/target/test-classes/,file:/home/www-data/.m2/repository/com/oracle/ojdbc6/11.2.0.3/ojdbc6-11.2.0.3.jar),liquibase.resource.FileSystemResourceAccessor(/home/www-data/workspace/database))
DEBUG 4/29/15 4:02 PM: liquibase: Release Database Lock
DEBUG 4/29/15 4:02 PM: liquibase: Executing UPDATE database command: UPDATE DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 4/29/15 4:02 PM: liquibase: Successfully released change log lock
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.111 s
[INFO] Finished at: 2015-04-29T16:02:15+10:00
[INFO] Final Memory: 10M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.2:update (default-cli) on project database: Error setting up or running Liquibase: liquibase.exception.SetupException: liquibase.exception.SetupException: liquibase.exception.SetupException: Cannot find base path 'src/main/resources/com/example/database/changelog/v000/master.xml' -> [Help 1]

知道我哪里错了。

1 个答案:

答案 0 :(得分:1)

以下更改似乎正在发挥作用。

pom.xml中的更改

<changeLogFile>target/classes/changelog-install.xml</changeLogFile
<propertyFile>target/classes/liquibase.properties</propertyFile>

com.obolus.database.changelog.v000 / master.xml

中的更改
<includeAll path="com/obolus/database/changelog/v000/tab"/>
<includeAll path="com/obolus/database/changelog/v000/cst"/>