执行 mvn liquibase:diff 时出现问题,其中快照用作目标 url

Problem while executing mvn liquibase:diff where snapshot us used as target url

使用 liquibase 和 maven spring 引导项目在数据库的一种状态下生成了快照后来尝试使用 mvn liquibase:diff[= 生成快照和在线数据库之间的差异28=].

liquibase.properties如下

changeLogFile=src/main/resources/bd.changeLog-base.xml
diffChangeLogFile=src/main/resources/bd.changeLog-base.xml
outputChangeLogFile=src/main/resources/liquibase-new-changeLog.xml
url=offline:mysql?snapshot=src/main/resources/snap_shot.json
driver=com.mysql.jdbc.Driver

referenceDriver=com.mysql.jdbc.Driver
referenceUrl=jdbc:mysql://localhost:3306/db_sample
referenceUsername=yyyy
referencePassword=xxxx

pom.xml

中使用以下maven插件依赖
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <!--<version>2.4.2</version>-->
        <version>2.2.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>Liquibaseapplicationexample</groupId>
    <artifactId>Liquibaseapplicationexample</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
        </dependency>
        
    </dependencies>
    
    <build>
        <finalName>liquibase-demo</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.5.5</version>
                
                <configuration>
                    <propertyFile>src/main/resources/liquibase/config/liquibase.properties</propertyFile>
                    <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-web</artifactId>
                        <version>2.2.2.RELEASE</version>
                    </dependency>

                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>
                        <version>2.2.2.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <profiles>
    <profile>
        <id>development</id>
        <properties>
            <build.profile.id>development</build.profile.id>
        </properties>
    </profile>
    </profiles>
</project>

我遇到以下错误。

[INFO] Scanning for projects...
[INFO]
[INFO] ------< Liquibaseapplicationexample:Liquibaseapplicationexample >-------
[INFO] Building Liquibaseapplicationexample 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.6.1:diff (default-cli) @ Liquibaseapplicationexample ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/liquibase/config/liquibase.properties
[INFO]   'outputChangeLogFile' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Starting Liquibase at Mon, 05 Apr 2021 01:21:53 IST (version 3.5.5 built at 2018-04-11 09:05:04)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.778 s
[INFO] Finished at: 2021-04-05T01:21:53+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.5:diff (default-cli) on project Liquibaseapplicationexample: Error setting up or running Li
quibase: liquibase.exception.UnexpectedLiquibaseException: Cannot parse snapshot offline:mysql?snapshot=src/main/resources/snap_shot.json: src/main/resources/snap_shot.j
son does not exist -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException.

请帮忙解决这个问题!

对我来说,通过将 liquibase-maven-plugin 从 3.5.5 版本升级到 3.10.1.

解决了这个问题
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.10.1</version>