我无法使用Liquibase生成初始更改日志

时间:2014-01-13 17:42:15

标签: java hibernate liquibase

我将使用shell中的Liquibase 3.1.0从 javax.persistence 带注释的类生成初始更改日志,这些类位于包 info.ggiv.cdr.commons.entity中。< / em> *我的项目。我已将 mysql-connector liquibase-hibernate4 库放在我的Liquibase安装的 lib 目录中。 Hibernate 3.4.0的库位于 / opt / java-lib / hibernate-orm / lib / all 文件夹中:

gg@VM-WrkEnv:/opt/java-lib/hibernate-orm/lib/all$ ls -l
összesen 124
lrwxrwxrwx 1 root root 56 jan   12 19:46 antlr-2.7.7.jar -> /opt/java-lib/hibernate-orm/lib/required/antlr-2.7.7.jar
lrwxrwxrwx 1 root root 62 jan   12 19:45 c3p0-0.9.2.1.jar -> /opt/java-lib/hibernate-orm/lib/optional/c3p0/c3p0-0.9.2.1.jar
lrwxrwxrwx 1 root root 56 jan   12 19:46 dom4j-1.6.1.jar -> /opt/java-lib/hibernate-orm/lib/required/dom4j-1.6.1.jar
lrwxrwxrwx 1 root root 71 jan   12 19:45 ehcache-core-2.4.3.jar -> /opt/java-lib/hibernate-orm/lib/optional/ehcache/ehcache-core-2.4.3.jar
lrwxrwxrwx 1 root root 76 jan   12 19:45 hibernate-c3p0-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/c3p0/hibernate-c3p0-4.3.0.Final.jar
lrwxrwxrwx 1 root root 86 jan   12 19:46 hibernate-commons-annotations-4.0.4.Final.jar -> /opt/java-lib/hibernate-orm/lib/required/hibernate-commons-annotations-4.0.4.Final.jar
lrwxrwxrwx 1 root root 71 jan   12 19:46 hibernate-core-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/required/hibernate-core-4.3.0.Final.jar
lrwxrwxrwx 1 root root 82 jan   12 19:45 hibernate-ehcache-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/ehcache/hibernate-ehcache-4.3.0.Final.jar
lrwxrwxrwx 1 root root 75 jan   12 19:45 hibernate-entitymanager-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/jpa/hibernate-entitymanager-4.3.0.Final.jar
lrwxrwxrwx 1 root root 71 jan   12 19:45 hibernate-envers-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/envers/hibernate-envers-4.3.0.Final.jar
lrwxrwxrwx 1 root root 88 jan   12 19:45 hibernate-infinispan-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/hibernate-infinispan-4.3.0.Final.jar
lrwxrwxrwx 1 root root 94 jan   12 19:45 hibernate-infinispan-4.3.0.Final-tests.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/hibernate-infinispan-4.3.0.Final-tests.jar
lrwxrwxrwx 1 root root 78 jan   12 19:46 hibernate-jpa-2.1-api-1.0.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/required/hibernate-jpa-2.1-api-1.0.0.Final.jar
lrwxrwxrwx 1 root root 93 jan   12 19:45 hibernate-jpamodelgen-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/jpa-metamodel-generator/hibernate-jpamodelgen-4.3.0.Final.jar
lrwxrwxrwx 1 root root 67 jan   12 19:46 hibernate-osgi-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/osgi/hibernate-osgi-4.3.0.Final.jar
lrwxrwxrwx 1 root root 82 jan   12 19:46 hibernate-proxool-4.3.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/proxool/hibernate-proxool-4.3.0.Final.jar
lrwxrwxrwx 1 root root 86 jan   12 19:45 infinispan-commons-6.0.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/infinispan-commons-6.0.0.Final.jar
lrwxrwxrwx 1 root root 83 jan   12 19:45 infinispan-core-6.0.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/infinispan-core-6.0.0.Final.jar
lrwxrwxrwx 1 root root 63 jan   12 19:46 jandex-1.1.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/required/jandex-1.1.0.Final.jar
lrwxrwxrwx 1 root root 64 jan   12 19:46 javassist-3.18.1-GA.jar -> /opt/java-lib/hibernate-orm/lib/required/javassist-3.18.1-GA.jar
lrwxrwxrwx 1 root root 67 jan   12 19:46 jboss-logging-3.1.3.GA.jar -> /opt/java-lib/hibernate-orm/lib/required/jboss-logging-3.1.3.GA.jar
lrwxrwxrwx 1 root root 82 jan   12 19:46 jboss-logging-annotations-1.2.0.Beta1.jar -> /opt/java-lib/hibernate-orm/lib/required/jboss-logging-annotations-1.2.0.Beta1.jar
lrwxrwxrwx 1 root root 83 jan   12 19:45 jboss-marshalling-1.3.18.GA.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/jboss-marshalling-1.3.18.GA.jar
lrwxrwxrwx 1 root root 89 jan   12 19:45 jboss-marshalling-river-1.3.18.GA.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/jboss-marshalling-river-1.3.18.GA.jar
lrwxrwxrwx 1 root root 98 jan   12 19:45 jboss-transaction-api_1.1_spec-1.0.1.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/jboss-transaction-api_1.1_spec-1.0.1.Final.jar
lrwxrwxrwx 1 root root 87 jan   12 19:46 jboss-transaction-api_1.2_spec-1.0.0.Final.jar -> /opt/java-lib/hibernate-orm/lib/required/jboss-transaction-api_1.2_spec-1.0.0.Final.jar
lrwxrwxrwx 1 root root 75 jan   12 19:45 jgroups-3.4.1.Final.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/jgroups-3.4.1.Final.jar
lrwxrwxrwx 1 root root 68 jan   12 19:45 link to slf4j-api-1.6.1.jar -> /opt/java-lib/hibernate-orm/lib/optional/ehcache/slf4j-api-1.6.1.jar
lrwxrwxrwx 1 root root 78 jan   12 19:45 mchange-commons-java-0.2.3.4.jar -> /opt/java-lib/hibernate-orm/lib/optional/c3p0/mchange-commons-java-0.2.3.4.jar
lrwxrwxrwx 1 root root 66 jan   12 19:46 org.osgi.compendium-4.3.1.jar -> /opt/java-lib/hibernate-orm/lib/osgi/org.osgi.compendium-4.3.1.jar
lrwxrwxrwx 1 root root 60 jan   12 19:46 org.osgi.core-4.3.1.jar -> /opt/java-lib/hibernate-orm/lib/osgi/org.osgi.core-4.3.1.jar
lrwxrwxrwx 1 root root 66 jan   12 19:46 proxool-0.8.3.jar -> /opt/java-lib/hibernate-orm/lib/optional/proxool/proxool-0.8.3.jar
lrwxrwxrwx 1 root root 83 jan   12 19:45 rhq-pluginAnnotations-3.0.4.jar -> /opt/java-lib/hibernate-orm/lib/optional/infinispan/rhq-pluginAnnotations-3.0.4.jar

当我使用以下命令启动Luquibase时

gg@VM-WrkEnv:~/Projektek/CDR/src/CDR-Commons/src/main/java$ /opt/liquibase/liquibase --changeLogFile=/home/gg/Projektek/CDR/src/CDR-Commons/src/main/resources/changelog.xml --referenceUrl=hibernate:spring:info.ggiv.cdr.commons.entity.account,info.ggiv.cdr.commons.entity.contact,info.ggiv.cdr.commons.entity.descriptor.ds,info.ggiv.cdr.commons.entity.descriptor.ds.entry.field,info.ggiv.cdr.commons.entity.ds,info.ggiv.cdr.commons.entity.ds.entry,info.ggiv.cdr.commons.entity.ds.enty.field,info.ggiv.cdr.commons.entity.ds.field.type,info.ggiv.cdr.commons.entity.ds.field.type.simple,info.ggiv.cdr.commons.entity.event,info.ggiv.cdr.commons.entity.localization,info.ggiv.cdr.commons.entity.organization,info.ggiv.cdr.commons.entity.ou,info.ggiv.cdr.commons.entity.owner?dialect=org.hibernate.dialect.MySQL5Dialect --url=jdbc:mysql://localhost/cdr --username=root --password=****** --classpath=/opt/java-lib/hibernate-orm/lib/all generateChangeLog

从我的来源所在的文件夹中,我得到以下输出

WARNING 2014.01.13. 18:11:liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 2014.01.13. 18:11:liquibase: Can not use class liquibase.ext.hibernate.database.HibernateEjb3Database as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 2014.01.13. 18:11:liquibase: Can not use class liquibase.ext.hibernate.database.HibernateClassicDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 2014.01.13. 18:11:liquibase: Can not use class liquibase.ext.hibernate.snapshot.SequenceSnapshotGenerator as a Liquibase service because org.hibernate.id.factory.IdentifierGeneratorFactory is not in the classpath
Liquibase 'generateChangeLog' Successful

并且生成的更改日志文件为空:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"/>

我做错了什么?谢谢!

2 个答案:

答案 0 :(得分:0)

尝试使用这个:https://liquibase.jira.com/wiki/display/CONTRIB/Hibernate+Integration。我想并非所有图书馆都被接受。

答案 1 :(得分:0)

classpath属性不支持jar目录,你需要单独包含hibernate jar。

更容易,您应该能够将/ hibernate jar添加到/ opt / liquibase / liquibase中的“lib”目录。 shell脚本将在其中找到所有jar并将它们添加到类路径中。