gpt4 book ai didi

spring - Liquibase 在 spring 项目中找不到我的实体类来生成差异

转载 作者:行者123 更新时间:2023-12-04 16:36:13 26 4
gpt4 key购买 nike

Liquibase 在给定的包中找不到我的实体类(JPA 注释)来生成差异。

当我使用 mvn liquibase:diff命令它说 未发现任何变化,无事可做 但我的实体有新的领域

我使用 spring 框架、JPA(hibernate)、Liquibase、liquibase-hibernate

这是我的代码:

liquibase.properties

referenceUrl=hibernate:spring:model.entity.persistent?dialect=org.hibernate.dialect.OracleDialect
changeLogFile=src/main/resources/liquibase-changeLog.xml
url=jdbc:oracle:thin:@localhost:1521:xe
username=username
password=password
driver=oracle.jdbc.OracleDriver
diffChangeLogFile=src/main/resources/liquibase-diff-changeLog-8.xml

pom.xml liquibase-hibernate 配置
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<executions>
<execution>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
<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>


<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.0.6</version>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.19</version>
</dependency>

</dependencies>
</plugin>

最佳答案

我尝试了以下..

pom.xml

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<propertyFile>liquibase.properties</propertyFile>
<changeLogFile>changelogs/db.changelog-master.xml</changeLogFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>3.6</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>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
</plugin>

</plugins>
</build>

liquibase.properties
referenceUrl=hibernate:spring:ch.karthi.liquibase.jpa.update.entities?dialect=org.hibernate.dialect.MySQL5Dialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceDefaultSchemaName=liquibasetest
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/liquibasetest
username=USERNAME
password=PASSWORD
defaultSchemaName=liquibasetest
changeLogFile=src/main/resources/liquibase-changeLog.xml
diffChangeLogFile=src/main/resources/liquibase-diff-changeLog-8.xml
outputChangeLogFile=src/main/resources/liquibase-changeLog.xml

它没有任何问题。
 [INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building liquibase-jpa-update 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.5.3:diff (default-cli) @ liquibase-jpa-update ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: liquibase.properties
[INFO] 'outputChangeLogFile' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:mysql://127.0.0.1:3306/liquibasetest

INFO 05.01.18, 12:58: liquibase-hibernate: Reading hibernate configuration hibernate:spring:ch.karthi.liquibase.jpa.update.entities?dialect=org.hibernate.dialect.MySQL5Dialect
INFO 05.01.18, 12:58: liquibase-hibernate: Found package ch.karthi.liquibase.jpa.update.entities
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
WARNING: An illegal reflective access operation has occurred
WARNING: Please consider reporting this to the maintainers of javassist.util.proxy.SecurityActions
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO 05.01.18, 12:58: liquibase-hibernate: Using dialect org.hibernate.dialect.MySQL5Dialect
[INFO] Performing Diff on database root@localhost @ jdbc:mysql://127.0.0.1:3306/liquibasetest (Default Schema: liquibasetest)
INFO 05.01.18, 12:58: liquibase-hibernate: Found table Customer
INFO 05.01.18, 12:58: liquibase-hibernate: Found table Customer
INFO 05.01.18, 12:58: liquibase-hibernate: Found table Customer
INFO 05.01.18, 12:58: liquibase-hibernate: Found primary key CustomerPK
INFO 05.01.18, 12:58: liquibase-hibernate: Found column id integer
INFO 05.01.18, 12:58: liquibase-hibernate: Found column age integer
INFO 05.01.18, 12:58: liquibase-hibernate: Found column name varchar(255)
INFO 05.01.18, 12:58: liquibase-hibernate: Found column sexString varchar(255)
INFO 05.01.18, 12:58: liquibase: src/main/resources/liquibase-diff-changeLog-8.xml exists, appending
[INFO] Differences written to Change Log File, src/main/resources/liquibase-diff-changeLog-8.xml
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.328 s
[INFO] Finished at: 2018-01-05T12:58:37+01:00
[INFO] Final Memory: 25M/85M
[INFO] ------------------------------------------------------------------------

关于spring - Liquibase 在 spring 项目中找不到我的实体类来生成差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48050793/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com