Spring Boot 1.5.8和Java 8在这里。我已遵循所有Spring Boot&Liquibase指南,但似乎无法使Liquibase正常工作。
这里是指向GitHub repo的链接,用于精确地再现问题,但这是独家新闻:
我有以下这样的MySQL v8数据库,它们是提前创建的(在应用运行之前):
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<p>Click on the box once, and use LEFT & RIGHT arrow (simulating swipes)</p>
<div id="slidetrack" tabindex="0"></div>
我有以下CREATE DATABASE IF NOT EXISTS troubleshooting_db CHARACTER SET utf8 COLLATE utf8_general_ci;
个文件:
src/main/resources/db/changelog
以及以下带有JPA注释的实体:
db.changelog-master.yaml:
===
databaseChangeLog:
- include:
file: db/changelog/1-setup.sql
1-setup.sql:
===
--liquibase formatted sql
--changeset troubleshooting:1 dbms:mysql
-- LOOKUPS
CREATE TABLE IF NOT EXISTS metric_range_categories (
metric_range_category_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
metric_range_category_ref_id VARCHAR(36) NOT NULL,
metric_range_category_name VARCHAR(250) NOT NULL,
metric_range_category_label VARCHAR(250) NOT NULL,
metric_range_category_description VARCHAR(500) NOT NULL,
CONSTRAINT pk_metric_range_categories PRIMARY KEY (metric_range_category_id),
INDEX idx_metric_range_categories_metric_range_category_ref_id (metric_range_category_ref_id),
INDEX idx_metric_range_categories_metric_range_category_label (metric_range_category_label),
CONSTRAINT uc_metric_range_categories_metric_range_category_ref_id UNIQUE (metric_range_category_ref_id),
CONSTRAINT uc_metric_range_categories_metric_range_category_name UNIQUE (metric_range_category_name),
CONSTRAINT uc_metric_range_categories_metric_range_category_label UNIQUE (metric_range_category_label)
);
-- Lots of other CREATE TABLE statements down here...
在运行时,出现以下异常:
@Entity
@Table(name = "metric_range_categories")
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name = "metric_range_category_id")),
@AttributeOverride(name = "refId", column = @Column(name = "metric_range_category_ref_id")),
@AttributeOverride(name = "name", column = @Column(name = "metric_range_category_name")),
@AttributeOverride(name = "label", column = @Column(name = "metric_range_category_label")),
@AttributeOverride(name = "description", column = @Column(name = "metric_range_category_description"))
})
public class MetricRangeCategory extends BaseLookup {
public MetricRangeCategory() {
}
public MetricRangeCategory(Long id, String refId, String name, String label, String description) {
super(id, refId, name, label, description);
}
}
因此,当它启动时,Liquibase 不会执行/执行,因此Hibernate JPA验证失败,因为它正在寻找不存在的表(因为Liquibase从来没有加入并完成了工作! )。关于我要去哪里的任何想法?为什么Liquibase不起作用?
答案 0 :(得分:2)
in the repo有2个不同的问题: