Liquibase 看不到实体的变化

     2023-02-26     46

关键词:

【中文标题】Liquibase 看不到实体的变化【英文标题】:Liquibase do not see changes in entities 【发布时间】:2015-01-23 09:16:05 【问题描述】:

我正在尝试使用 liquibase 配置简单的 maven 项目。我有很多关于 liquibase-maven-plugin 和 liquibase-hibernate4 版本的问题,它们不会产生大的堆栈跟踪,但最后我几乎让它工作了。但是当我执行 mvn liquibase:diff 时,它以消息 liquibase: No changes found, nothing to do 结尾。

这是我的 pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>pl.mlewando.ff</groupId>
    <artifactId>liquibase_test</artifactId>
    <version>1.0</version>

    <dependencies>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.7.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.6.Final</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.14.8</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.32</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <changeLogFile>src/main/resources/db/db.changelog.xml</changeLogFile>
                    <diffChangeLogFile>src/main/resources/db/generated-db.changelog.xml</diffChangeLogFile>
                    <driver>com.mysql.jdbc.Driver</driver>
                    <url>jdbc:mysql://localhost:3306/liquibase_test?characterEncoding=utf8</url>
                    <username>root</username>
                    <password>root</password>
                    <referenceUrl>hibernate:spring:pl.mlewando.ff.model?dialect=org.hibernate.dialect.MySQL5InnoDBDialect</referenceUrl>
                    <verbose>true</verbose>
                    <logging>debug</logging>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate4</artifactId>
                        <version>3.4</version>
                    </dependency>

                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.32</version>
                    </dependency>

                    <dependency>
                        <groupId>org.springframework.data</groupId>
                        <artifactId>spring-data-jpa</artifactId>
                        <version>1.7.0.RELEASE</version>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>4.3.6.Final</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

并从mvn liquibase:diff登录:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building liquibase_test_backend 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.2.1:diff (default-cli) @ liquibase_test_backend ---
[INFO] ------------------------------------------------------------------------
[INFO] Loading artfacts into URLClassLoader
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/data/spring-data-jpa/1.7.0.RELEASE/spring-data-jpa-1.7.0.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/data/spring-data-commons/1.9.0.RELEASE/spring-data-commons-1.9.0.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-orm/4.0.7.RELEASE/spring-orm-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-jdbc/4.0.7.RELEASE/spring-jdbc-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-expression/4.1.1.RELEASE/spring-expression-4.1.1.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-aop/4.0.7.RELEASE/spring-aop-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-tx/4.0.7.RELEASE/spring-tx-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-beans/4.0.7.RELEASE/spring-beans-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-core/4.0.7.RELEASE/spring-core-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/aspectj/aspectjrt/1.8.2/aspectjrt-1.8.2.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.6.Final/hibernate-entitymanager-4.3.6.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/hibernate-core/4.3.6.Final/hibernate-core-4.3.6.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/projectlombok/lombok/1.14.8/lombok-1.14.8.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/IdeaProjects/forfun/liquibase_test/backend/target/classes/
[INFO]   artifact: file:/C:/Users/mlewandowski/IdeaProjects/forfun/liquibase_test/backend/target/test-classes
[INFO] ------------------------------------------------------------------------
[INFO] Settings
----------------------------
[INFO]     driver: com.mysql.jdbc.Driver
[INFO]     url: jdbc:mysql://localhost:3306/liquibase_test?characterEncoding=utf8
[INFO]     username: root
[INFO]     password: *****
[INFO]     use empty password: false
[INFO]     properties file: null
[INFO]     properties file will override? false
[INFO]     prompt on non-local database? true
[INFO]     clear checksums? false
[INFO]     changeLogFile: src/main/resources/db/db.changelog.xml
[INFO]     context(s): null
[INFO]     referenceDriver: null
[INFO]     referenceUrl: hibernate:spring:pl.mlewando.ff.model?dialect=org.hibernate.dialect.MySQL5InnoDBDialect
[INFO]     referenceUsername: null
[INFO]     referencePassword: null
[INFO]     referenceDefaultSchema: null
[INFO]     diffChangeLogFile: src/main/resources/db/generated-db.changelog.xml
[INFO] ------------------------------------------------------------------------
DEBUG 25.11.14 12:07: liquibase: Connected to root@localhost@jdbc:mysql://localhost:3306/liquibase_test?characterEncoding=utf8
DEBUG 25.11.14 12:07: liquibase: Setting auto commit to false from true
[INFO] Executing on Database: jdbc:mysql://localhost:3306/liquibase_test?characterEncoding=utf8
[INFO] Loading artfacts into URLClassLoader
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/data/spring-data-jpa/1.7.0.RELEASE/spring-data-jpa-1.7.0.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/data/spring-data-commons/1.9.0.RELEASE/spring-data-commons-1.9.0.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-orm/4.0.7.RELEASE/spring-orm-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-jdbc/4.0.7.RELEASE/spring-jdbc-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-expression/4.1.1.RELEASE/spring-expression-4.1.1.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-aop/4.0.7.RELEASE/spring-aop-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-tx/4.0.7.RELEASE/spring-tx-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-beans/4.0.7.RELEASE/spring-beans-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/springframework/spring-core/4.0.7.RELEASE/spring-core-4.0.7.RELEASE.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/aspectj/aspectjrt/1.8.2/aspectjrt-1.8.2.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.6.Final/hibernate-entitymanager-4.3.6.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/hibernate-core/4.3.6.Final/hibernate-core-4.3.6.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/org/projectlombok/lombok/1.14.8/lombok-1.14.8.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/.m2/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar
[INFO]   artifact: file:/C:/Users/mlewandowski/IdeaProjects/forfun/liquibase_test/backend/target/classes/
[INFO]   artifact: file:/C:/Users/mlewandowski/IdeaProjects/forfun/liquibase_test/backend/target/test-classes
[INFO] ------------------------------------------------------------------------
DEBUG 25.11.14 12:07: liquibase: Connected to null@hibernate:spring:pl.mlewando.ff.model?dialect=org.hibernate.dialect.MySQL5InnoDBDialect
DEBUG 25.11.14 12:07: liquibase: Not adjusting the auto commit mode; it is already false
INFO 25.11.14 12:07: liquibase-hibernate: Reading hibernate configuration hibernate:spring:pl.mlewando.ff.model?dialect=org.hibernate.dialect.MySQL5InnoDBDialect
INFO 25.11.14 12:07: liquibase-hibernate: Found package pl.mlewando.ff.model
INFO 25.11.14 12:07: liquibase-hibernate: Found dialect org.hibernate.dialect.MySQL5InnoDBDialect
INFO 25.11.14 12:07: liquibase-hibernate: Found hibernate.enhanced_idfalse
lis 25, 2014 12:07:37 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
        name: default
        ...]
lis 25, 2014 12:07:37 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core 4.3.1.Final
lis 25, 2014 12:07:37 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
lis 25, 2014 12:07:37 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
lis 25, 2014 12:07:37 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations 4.0.5.Final
lis 25, 2014 12:07:37 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
INFO 25.11.14 12:07: liquibase-hibernate: Using dialect org.hibernate.dialect.MySQL5InnoDBDialect
[INFO] Performing Diff on database root@localhost @ jdbc:mysql://localhost:3306/liquibase_test?characterEncoding=utf8 (Default Schema: liquibase_test)
DEBUG 25.11.14 12:07: liquibase: Computed checksum for 1416913657501 as 5fde170700e5d1ee87d42598486086ef
INFO 25.11.14 12:07: liquibase-hibernate: Found table User
INFO 25.11.14 12:07: liquibase-hibernate: Found table User
INFO 25.11.14 12:07: liquibase-hibernate: Found column id bigint
INFO 25.11.14 12:07: liquibase-hibernate: Found column name varchar(255)
INFO 25.11.14 12:07: liquibase-hibernate: Found primary key UserPK
INFO 25.11.14 12:07: liquibase: src\main\resources\db\generated-db.changelog.xml exists, appending
DEBUG 25.11.14 12:07: liquibase: MissingObjectChangeGenerator type order:     liquibase.structure.core.Catalog    liquibase.structure.core.Schema    liquibase.structure.core.Sequence    liquibase.structure.core.StoredProcedure    liquibase.structure.core.Table    liquibase.structure.core.Column    liquibase.structure.core.PrimaryKey    liquibase.structure.core.UniqueConstraint    liquibase.structure.core.ForeignKey    liquibase.structure.core.Index    liquibase.structure.core.View
DEBUG 25.11.14 12:07: liquibase: UnexpectedObjectChangeGenerator type order:     liquibase.structure.core.Catalog    liquibase.structure.core.ForeignKey    liquibase.structure.core.Schema    liquibase.structure.core.StoredProcedure    liquibase.structure.core.UniqueConstraint    liquibase.structure.core.View    liquibase.structure.core.Table    liquibase.structure.core.PrimaryKey    liquibase.structure.core.Column    liquibase.structure.core.Index    liquibase.structure.core.Sequence
DEBUG 25.11.14 12:07: liquibase: ChangedObjectChangeGenerator type order:     liquibase.structure.core.Catalog    liquibase.structure.core.ForeignKey    liquibase.structure.core.Schema    liquibase.structure.core.Sequence    liquibase.structure.core.StoredProcedure    liquibase.structure.core.Table    liquibase.structure.core.Column    liquibase.structure.core.PrimaryKey    liquibase.structure.core.Index    liquibase.structure.core.UniqueConstraint    liquibase.structure.core.View
INFO 25.11.14 12:07: liquibase: No changes found, nothing to do
[INFO] Differences written to Change Log File, src/main/resources/db/generated-db.changelog.xml
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.129 s
[INFO] Finished at: 2014-11-25T12:07:37+01:00
[INFO] Final Memory: 20M/308M
[INFO] ------------------------------------------------------------------------

src/main/java/pl/mlewando/ff/model 我有一个简单的类:

package pl.mlewando.ff.model;

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
@Data
class User 
    @Id
    private long id;
    private String name;

persistence.xml 中的src/main/resources/META-INF/

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">
    <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
        </properties>
    </persistence-unit>
</persistence>

数据库liquibase_test 是空的,当我用空的db.changelog.xml 执行mvn liquibase:update 时,它会创建表databasechangelogdatabasechangeloglock,但是之后当我运行mvn liquibase:diff 时它仍然看不到用户表。

我做错了什么?谢谢!

编辑:

当我尝试使用此命令从命令行区分时:

liquibase 
      --driver=com.mysql.jdbc.Driver 
      --url=jdbc:mysql://localhost:3306/liquibase_test_ref 
      --username=root 
      --password=root 
    diffChangeLog 
      --referenceUrl="hibernate:spring:pl.mlewando.ff.model?dialect=org.hibernate.dialect.MySQL5InnoDBDialect"

一切正常,我最终得到了这个变更日志:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 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.2.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <changeSet author="mlewandowski (generated)" id="1416923630350-1">
        <createTable tableName="User">
            <column name="id" type="BIGINT">
                <constraints nullable="false"/>
            </column>
            <column name="name" type="VARCHAR(255)"/>
        </createTable>
    </changeSet>
    <changeSet author="mlewandowski (generated)" id="1416923630350-2">
        <addPrimaryKey columnNames="id" constraintName="UserPK" tableName="User"/>
    </changeSet>
</databaseChangeLog>

我有 3.2.1 版的 liquibase(与 pom.xml 中的相同)和类路径上的这些 jar:

antlr-2.7.7.jar
aopalliance-1.0.jar
aspectjrt-1.8.2.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-4.0.5.Final.jar
hibernate-core-4.3.1.Final.jar
hibernate-entitymanager-4.3.6.Final.jar
hibernate-envers-4.3.1.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
jcl-over-slf4j-1.7.7.jar
liquibase_test_backend-1.0.jar
liquibase-hibernate4-3.4.jar
mysql-connector-java-5.1.33.jar
slf4j-api-1.7.7.jar
snakeyaml-1.13.jar
spring-aop-4.0.7.RELEASE.jar
spring-beans-4.0.7.RELEASE.jar
spring-context-4.1.1.RELEASE.jar
spring-core-4.0.7.RELEASE.jar
spring-data-commons-1.9.0.RELEASE.jar
spring-data-jpa-1.7.0.RELEASE.jar
spring-expression-4.1.1.RELEASE.jar
spring-jdbc-4.0.7.RELEASE.jar
spring-orm-4.0.7.RELEASE.jar
spring-tx-4.0.7.RELEASE.jar
xml-apis-1.0.b2.jar

但我真的很想通过 maven 来做。所以,再说一遍:我做错了什么?

【问题讨论】:

这只是一个假设,因为我只有非常空闲的 Liquibase 经验,但 diff 命令是否有可能以 changeSet 的形式引用基于 liquibase 的更改,而不是数据库本身的更改(与以前的版本相比)。例如。假设您告诉 Liquibase“创建一个表用户”,然后用“删除一个表用户”替换该 liquibase 配置 - liquibase 不会认为这是要应用的更改,因此它显然会导致数据库结构的更改。了解我要描述的内容吗? (另外:你根本没有任何更改文件吗?o.O) 我还没有任何更改文件,只有最初的一个:&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;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"/&gt; 关于Understood what i am trying to describe? - 不幸的是没有:( 但是我有空数据库,空的初始更改日志和项目中的新实体。 好的。抱歉,英语不是我的母语,因此有时我很难清楚地表达自己。然而,我试图描述的内容不再重要,因为据我记得正确 Liquibase 不会与您的(带注释的)实体交互,除非配置为这样做(例如,只有在为 Liquibase 定义了适当的变更集时才会创建表用户这样做)。但是,我此时将我注销,因为我也可能是错的 - 希望有人可以进一步帮助您,尤其是在 Spring+Liquibase 方面。 Liquibase 不会查看差异中的变更集。它只是查看您的数据库和休眠类并生成更改集。您可能遇到了与 Liquibase 3.2.1 和 liquibase-hibernate 扩展的兼容性问题。我正在完成对扩展的更新,以确保它适用于今天或明天应该发布的最新 liquibase 3.3.1。可以用最新版本重新测试吗? 好的,我会尽快重新测试新版本,但是当我尝试不同版本的 liquibase-maven-plugin 和 liquibase-hibernate4 时,我发现只有 3.2.1 形式的 maven 插件和3.4 用于扩展工程。其他版本给了我很多空指针和方法未找到异常。而且,正如我已经检查过的,我的版本在命令行中运行良好。 【参考方案1】:

我不确定这是否相关,但前段时间我在liquibase-hibernate-plugin 上发现了一个类似的错误。我使用的是带有 hiberante 4 的 Spring 本地会话工厂,但它也没有发现变化。

调试后我发现liquibase-hibernate-plugin 使用import org.springframework.orm.hibernate3.LocalSessionFactoryBean;HibernateSpringDatabase.java,因此它无法读取我的配置。

我更改了它并生成了一个拉取请求,现在它对我来说可以正常工作了。

如果您想尝试一下,可以使用我更改的 liquibase-hibernate-plugin 使用以下 maven 依赖项:

<dependency>
    <groupId>com.github.malaguna</groupId>
    <artifactId>liquibase-hibernate</artifactId>
    <version>liquibase-hibernate4-3.6.1</version>
</dependency>

但是首先你必须将 JitPack repo 添加到 maven pom.xml:

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

希望对你有帮助!

【讨论】:

这个仓库还存在吗?因为当我在我的pom.xml 中添加它时,它引发了异常org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.github.malaguna:liquibase-hibernate:jar:liquibase-hibernate4-3.6.1 in central (https://repo.maven.apache.org/maven2) 不再需要了,他们接受了我的拉取请求,现在它在主流版本的 liquibase-hibernate 插件中得到了解决,但我没有放弃我的 repo。您面临的问题是我的包不在 maven Central 中,正如我在回答中所说,您必须配置 jitpack 存储库。

为啥 liquibase 总是使用自己的序列?

】为啥liquibase总是使用自己的序列?【英文标题】:Whyliquibasedoesalwaysuseitsownsequence?为什么liquibase总是使用自己的序列?【发布时间】:2017-10-0223:06:45【问题描述】:我正在使用liquibase作为我当前项目的迁移工具。问题是我正在... 查看详情

liquibase使用小结

  简介Liquibase是一个用于跟踪、管理和应用数据库变化的开源数据库重构工具。它将所有数据库的变化保存在XML文件中,便于版本控制和项目部署升级。本文档以TC标注中的任务管理模块(dw-digit-manager)示例,简要说明liquiba... 查看详情

liquibase了解

Liquibase是一个用于跟踪、管理和应用数据库变化的开源的数据库重构工具。它将所有数据库的变化(包括结构和数据)都保存在XML文件中,便于版本控制。Liquibase具备如下特性:不依赖于特定的数据库,目前支持包括Oracle/SqlServe... 查看详情

如何修复“在当前项目和插件组中找不到前缀'liquibase'的插件”

】如何修复“在当前项目和插件组中找不到前缀\\\'liquibase\\\'的插件”【英文标题】:Howtofix"Nopluginfoundforprefix\'liquibase\'inthecurrentprojectandintheplugingroups"如何修复“在当前项目和插件组中找不到前缀\'liquibase\'的插件”【发... 查看详情

如何使用 JHipster 和 Liquibase 更新现有数据库? [复制]

】如何使用JHipster和Liquibase更新现有数据库?[复制]【英文标题】:HowtoupdateaexistentdatabaseusingJHipsterandLiquibase?[duplicate]【发布时间】:2020-01-2011:55:26【问题描述】:Jhipster为我们创建了一个初始项目结构,但通常在活动应用程序中... 查看详情

单元测试中的 jOOQ + Liquibase + H2 导致“找不到模式”异常

】单元测试中的jOOQ+Liquibase+H2导致“找不到模式”异常【英文标题】:jOOQ+Liquibase+H2inunittestresultsin"schemanotfound"exception【发布时间】:2018-07-2611:07:37【问题描述】:我正在为一些数据访问代码编写单元测试。设置中的关键... 查看详情

Hibernate 不使用 Liquibase 中定义的序列

】Hibernate不使用Liquibase中定义的序列【英文标题】:HibernatenotusingsequencedefinedinLiquibase【发布时间】:2018-02-0813:44:04【问题描述】:我在liquibase更改日志中定义了一个序列,但看起来Hibernate在插入实体时忽略了它。Liquibase中定义... 查看详情

liquibase.exception.DatabaseException JHipster 框架

】liquibase.exception.DatabaseExceptionJHipster框架【英文标题】:liquibase.exception.DatabaseExceptionJHipsterFramework【发布时间】:2017-11-3021:55:20【问题描述】:我正在使用JHipster框架,并且我创建了一个带有Blob图像字段的子生成器的实体。在这... 查看详情

Liquibase 如何标记 - 命令行

】Liquibase如何标记-命令行【英文标题】:HowdoesLiquibaseTag-commandline【发布时间】:2015-04-2803:04:39【问题描述】:我能够使用liquibase命令行成功标记,但不知道它的标记和存储位置。命令执行成功,下面是tag命令的输入和响应。这... 查看详情

Liquibase:diff 总是生成索引

】Liquibase:diff总是生成索引【英文标题】:Liquibase:diffalwaysgeneratesindexes【发布时间】:2018-02-1115:19:03【问题描述】:我使用spring-boot和liquibase-maven-plugin来根据我的类生成数据库更改,但是“mvncompileliquibase:diff”命令总是生成索... 查看详情

H2 - Oracle - liquibase - org.h2.jdbc.JdbcSQLException:找不到表“all_sequences”;

】H2-Oracle-liquibase-org.h2.jdbc.JdbcSQLException:找不到表“all_sequences”;【英文标题】:H2-Oracle-liquibase-org.h2.jdbc.JdbcSQLException:Table"all_sequences"notfound;【发布时间】:2019-02-0817:25:43【问题描述】:我尝试将用于测试目的的H2添加... 查看详情

无法与 liquibase gradle 插件生成差异

】无法与liquibasegradle插件生成差异【英文标题】:Unabletogeneratedifferencefromliquibasegradleplugin【发布时间】:2016-06-1311:38:56【问题描述】:我正在尝试使用MYSQL数据库在现有SpringBoot项目中实现liquibase。我希望能够生成更改集,指定实... 查看详情

实体框架迁移 API

】实体框架迁移API【英文标题】:EntityFrameworkMigrationAPI【发布时间】:2017-08-0919:24:46【问题描述】:您好,我在实体框架之上创建了一个数据同步项目。该框架在某种程度上独立于模式。我想让它更能容忍模式的变化,即使是目... 查看详情

异步执行长时间运行的 liquibase 数据库更新

】异步执行长时间运行的liquibase数据库更新【英文标题】:Executelongrunningliquibasedatabaseupdatesasynchronously【发布时间】:2018-02-2701:08:18【问题描述】:我们正在使用liquibase来管理应用程序底层关系数据库结构的变化。我们使用Postgre... 查看详情

Liquibase maven:spring-boot启动时找不到更改日志位置

】Liquibasemaven:spring-boot启动时找不到更改日志位置【英文标题】:Liquibasemaven:Cannotfindchangeloglocationwhenspring-bootstarts【发布时间】:2018-12-1416:38:01【问题描述】:我的liquibasemaven插件配置是:<plugin><groupId>org.liquibase</grou... 查看详情

liquibase diff 不起作用

】liquibasediff不起作用【英文标题】:liquibasediffdoesnotworks【发布时间】:2020-05-0123:19:54【问题描述】:我正在尝试使用Hibernate和Liquibase使用Code-First方法制作SpringBoot2.2.x应用程序(Java13)。我想根据实体对象和数据库之间的差异生成... 查看详情

Elasticsearch 的 Liquibase 或 Flyway 数据库迁移替代方案

】Elasticsearch的Liquibase或Flyway数据库迁移替代方案【英文标题】:LiquibaseorFlywaydatabasemigrationalternativeforElasticsearch【发布时间】:2014-07-2113:50:17【问题描述】:我对ES很陌生。我一直在尝试寻找一个数据库迁移工具,但我找不到。... 查看详情

有没有办法让 NSFetchedResultsController 检测多个实体的变化?

】有没有办法让NSFetchedResultsController检测多个实体的变化?【英文标题】:IsthereawaytohaveNSFetchedResultsControllerdetectchangesinmorethanoneentity?【发布时间】:2013-04-2713:12:14【问题描述】:我有一个包含3个实体的简单CoreData模型的应用:BAC... 查看详情