Liquibase JPA配置的referenceUrl [英] Liquibase JPA configuration of the referenceUrl

查看:276
本文介绍了Liquibase JPA配置的referenceUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用 liquibase 在我的数据库中构建带有JPA注释的类diff变更集. 不过,我对几件事还是很困惑.

I am struggling to build the JPA annotated classes diff changesets against my database, using liquibase. Still, I am very confused about few things.

我使用以下内容:

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文件.

and a normal persistence.xml file with standard JPA configuration.

我收到一条错误消息: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)

I get an error which says : 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. 使用JPA(带注释的实体)和liquibase进行休眠

I am confused because the below answer says that we need a hibernate.cfg.xml file (even I have persistence.xml instead), but then he says that we can use some url's which are defined on wiki page. Hibernate using JPA (annotated Entities) and liquibase

Wiki页面上说,如果需要使用JPA,我们可以在三种类型的URL之间进行选择.

Wiki page says that if we need to use JPA, we can choose between three types of URL's.

hibernate:ejb3:myPersistenceUnit
hibernate:ejb3:com.example.MyConfigFactory
hibernate:ejb3:myPersistenceUnit?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy

因此,我选择第一个,并在liquidbase.properties中将其设置为referenceUrl.

So, I choose the first one, and I've set in the liquidbase.properties this as referenceUrl.

此外,在Wiki页面上也提到了:( https://github.com/liquibase/liquibase-hibernate/wiki )

Also, on the wiki page it is mentioned : (https://github.com/liquibase/liquibase-hibernate/wiki)

如果您使用的是Liquibase的命令行版本,则只需 必须将liquibase-hibernate [3 | 4] .jar文件添加到 LIQUIBASE_HOME/lib目录.

If you are using the command line version of Liquibase, you simply have to add the liquibase-hibernate[3|4].jar file to the LIQUIBASE_HOME/lib directory.

我也是这样做的. 仍然,不起作用.有人可以向我解释我在想什么吗?

I did this too. Still, doesnt work. Can someone explain me somewhow what am I missing ?

非常感谢!

推荐答案

问题是您正在使用"java -jar"调用liquibase. jar中的Class-path行无法从lib目录中拾取其他jar,因此liquibase-hibernate.jar不包含在classpath中.

The problem is that you are calling liquibase with "java -jar". The Class-path line in the jar can't pick up additional jars from the lib directory and so the liquibase-hibernate.jar is not being included in the classpath.

使用liquibase jar中包含的sh/bat文件运行liquibase:real_path/liquibase[.bat] diffChangeLog

Run liquibase using the sh/bat file included in the liquibase jar: real_path/liquibase[.bat] diffChangeLog

这篇关于Liquibase JPA配置的referenceUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆