使用liquibase-hibernatate插件"Cannot find database driver: Driver class was not specified and could not



我正在尝试从数据库和持久性实体之间的diff生成changeLog

我正在使用 liquibase 休眠插件

<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> 

我的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

执行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]

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

问题出在我liquibase.properties referenceUrl 引用网址正在使用包扫描,所以网址必须以hibernate:spring:开头。

我变了

referenceUrl=com.sample.App?=org.hibernate.dialect.PostgreSQLDialect

referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect

这解决了我的问题。

相关内容

最新更新