使用 liquibase-hibernate 插件时出现“找不到数据库驱动程序:未指定驱动程序类且无法从 url 确定”错误

JIT*_*HIN 4 liquibase liquibase-hibernate

我正在尝试changeLogdiff数据库和持久性实体之间的 s 生成。

我正在使用 liquibase hibernate 插件

<plugins>
    <plugin>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-maven-plugin</artifactId>
        <version>3.4.1</version>
        <configuration>                  
            <propertyFile>src/main/resources/liquibase.properties</propertyFile>
        </configuration> 
        <dependencies>
            <dependency>
                <groupId>org.liquibase.ext</groupId>
                <artifactId>liquibase-hibernate4</artifactId>
                <version>3.5</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>4.1.7.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-jpa</artifactId>
                <version>1.7.3.RELEASE</version>
            </dependency>
        </dependencies>               
    </plugin> 
</plugins> 
Run Code Online (Sandbox Code Playgroud)

我的liquibase.properties情况是这样的

changeLogFile=classpath:liquibase-changeLog.xml
url=jdbc:postgres://localhost:5432/oauth_reddit
username=tutorialuser
password=tutorialmy5ql
driver=org.postgresql.Driver
referenceUrl=com.sample.App
  ?dialect=org.hibernate.dialect.PostgreSQLDialect
diffChangeLogFile=src/main/resources/liquibase-diff-changeLog.xml
Run Code Online (Sandbox Code Playgroud)

执行时mvn liquibase:diff,我收到以下错误

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:diff (default-cli) on project prototype-liquibase-migration: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect) -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

我已经在属性Driver中指定了liquibase,但似乎没有使用。我可能做错了什么?

JIT*_*HIN 6

问题出referenceUrl在我的liquibase.propertiesReferenceUrl 正在使用包扫描,因此 url 必须以hibernate:spring:.

我变了

referenceUrl=com.sample.App?=org.hibernate.dialect.PostgreSQLDialect
Run Code Online (Sandbox Code Playgroud)

进入

referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题。