我正在尝试从数据库实体和持久性实体之间的-8
生成changeLog
。
我正在使用liquibase休眠插件
diff
我的<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]
属性中指定了Driver
,但似乎没有用。我可能做错了什么?
答案 0 :(得分:0)
问题出在我的referenceUrl
中的liquibase.properties
上,referenceUrl正在使用程序包扫描,因此该网址必须以hibernate:spring:
开头。
我将referenceUrl=com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
更改为referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
。
这解决了我的问题。