在启动spring引导应用程序时,我试图创建一个基本的数据库结构。启动任务时,我需要这样做:bootRun是由液化库运行的。
它启动时没有错误,创建了到数据库的连接,但清算库没有启动。它不会产生错误,日志中也没有关于它的信息。
为什么它不自动启动与弹簧引导?
build.gradle
plugins {
id 'org.springframework.boot' version '3.0.0-SNAPSHOT'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'spring.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5:3.1.0.M1'
implementation group: 'org.liquibase', name: 'liquibase-core', version: '4.12.0'
runtimeOnly'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
compileOnly 'org.projectlombok:lombok'
}
tasks.named('test') {
useJUnitPlatform()
}application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/db
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/changelog/db.changelog-root.yamlsrc/db/changelog/db.changelog-root.yaml
databaseChangeLog:
- logicalFilePath: db/changelog/db.changelog-root.yaml
- changeSet:
id: create-a-structure
author: your_liquibase_username
changes:
- createTable:
tableName: app_user
columns:
- column:
name: id
type: BIGINT
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: username
type: varchar(254)
constraints:
unique: true
nullable: false
- column:
name: password
type: varchar(64)
constraints:
nullable: false
- column:
name: first_name
type: varchar(50)
nullable: false
- column:
name: last_name
type: varchar(50)
nullable: false发布于 2022-07-07 22:53:02
我认为changelog文件的spring属性不应该有类路径引用:
spring.liquibase.change-log=db/...而不是
spring.liquibase.change-log=classpath:db/...发布于 2022-10-26 08:13:30
我也有过类似的问题。这为我解决了https://stackoverflow.com/a/41960712/3999476
我有一个多模块maven项目,我必须移动依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>添加了对清算库的依赖关系的模块。
发布于 2022-07-07 23:17:14
刚刚注意到你把液化基yaml放进了:src/db/changelog/db.changelog-root.yaml。因为指定的值是:spring.liquibase.change-log=classpath:db/changelog/db.changelog-root.yaml
你能把文件放进:
src/main/resources/db/changelog/db.changelog-root.yaml
https://stackoverflow.com/questions/72901533
复制相似问题