Liquibase找不到我的实体类来在spring项目中生成diff
作者:互联网
Liquibase无法在给定包中找到我的实体类(JPA注释)来生成diff.
当我使用mvn liquibase:diff命令它说没有发现任何变化,无所事事,但我的实体有新的字段
我使用spring framweork,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 config
<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,hibernate,database-migration,liquibase,liquibase-hibernate 来源: https://codeday.me/bug/20190705/1389533.html