问题描述
我正在尝试从数据库和持久性实体之间的 diff
s生成 changeLog
.
I am trying to generate changeLog
from diff
s between a Database and Persistence Entities.
我正在使用liquibase休眠插件
I am using the liquibase hibernate plugin
<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
时,出现以下错误
while executing mvn liquibase:diff
, I am getting the following error
[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
,但似乎没有用.我可能做错了什么?
I have specified the Driver
in the liquibase
properties, but it seems that it is not taking.What could have I done wrong ?
推荐答案
问题出在我的 liquibase.properties
中的 referenceUrl
上,referenceUrl正在使用程序包扫描,因此网址必须以 hibernate:spring:
开头.
The problem was with my referenceUrl
in liquibase.properties
The referenceUrl is using package scan, so the url has to start with hibernate:spring:
.
我改变了
referenceUrl=com.sample.App?=org.hibernate.dialect.PostgreSQLDialect
进入
referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
这解决了我的问题.
这篇关于“找不到数据库驱动程序:未指定驱动程序类,并且无法从url确定"使用liquibase-hibernate插件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!