【发布时间】:2013-11-17 13:37:54
【问题描述】:
我正在努力使用 liquibase 针对我的数据库构建 JPA 带注释的类差异变更集。
尽管如此,我还是对一些事情感到困惑。
我使用以下:
liquibase.properties
#liquibase.properties
driver: org.postgresql.Driver
classpath: real_path/.m2/repository/org/postgresql/postgresql/9.2-1002-jdbc4/postgresql-9.2-1002-jdbc4.jar
url: jdbc:postgresql://localhost:5432/diquiz
username: postgres
password: postgres
referenceUrl: hibernate:ejb3:diQuiz
referenceUsername: postgres
referencePassword: postgres
changeLogFile: changelog-master.xml
和
java -jar real_path\liquibase-core-3.0.6.jar diffChangeLog
以及具有标准 JPA 配置的普通 persistence.xml 文件。
我收到一条错误消息:Liquibase diffChangeLog Failed: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:ejb3:unit)
我很困惑,因为下面的答案说我们需要一个 hibernate.cfg.xml 文件(即使我有 persistence.xml 代替),但是他说我们可以使用一些在 wiki 页面上定义的 url。
Hibernate using JPA (annotated Entities) and liquibase
Wiki 页面说如果我们需要使用 JPA,我们可以在三种类型的 URL 中进行选择。
hibernate:ejb3:myPersistenceUnit
hibernate:ejb3:com.example.MyConfigFactory
hibernate:ejb3:myPersistenceUnit?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
所以,我选择了第一个,并在liquidbase.properties中设置为referenceUrl。
另外,在 wiki 页面上提到:(https://github.com/liquibase/liquibase-hibernate/wiki)
如果您使用的是 Liquibase 的命令行版本,您只需 必须将 liquibase-hibernate[3|4].jar 文件添加到 LIQUIBASE_HOME/lib 目录。
我也是这样做的。 仍然,不起作用。有人可以以某种方式解释我缺少什么吗?
非常感谢!
【问题讨论】: