我正在尝试设置克隆的 Spring boot 项目,但出现以下错误。
2024-04-27 13:47:46.737 INFO 56344 --- [ restartedMain] o.f.c.i.database.base.DatabaseType : Database: jdbc:h2:mem:bbb31b5d-c608-49e8-a693-b1a87d0159db (H2 1.4)
2024-04-27 13:47:46.846 INFO 56344 --- [ restartedMain] o.f.core.internal.command.DbValidate : Successfully validated 7 migrations (execution time 00:00.045s)
2024-04-27 13:47:46.858 INFO 56344 --- [ restartedMain] o.f.c.i.s.JdbcTableSchemaHistory : Creating Schema History table "PUBLIC"."flyway_schema_history" ...
2024-04-27 13:47:46.897 INFO 56344 --- [ restartedMain] o.f.c.i.s.DefaultSqlScriptExecutor : 0 rows affected
2024-04-27 13:47:46.902 INFO 56344 --- [ restartedMain] o.f.c.i.s.DefaultSqlScriptExecutor : 0 rows affected
2024-04-27 13:47:46.927 INFO 56344 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": << Empty Schema >>
2024-04-27 13:47:46.942 INFO 56344 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version "1.0 - CREATE TABLE"
2024-04-27 13:47:46.947 ERROR 56344 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Migration of schema "PUBLIC" to version "1.0 - CREATE TABLE" failed! Please restore backups and roll back database and code!
2024-04-27 13:47:46.965 ERROR 56344 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V1_0__CREATE_TABLE.sql failed
---------------------------------------
SQL State : 90079
Error Code : 90079
Message : Schema "AAC_SCHEMA" not found; SQL statement:
CREATE TABLE AAC_SCHEMA.SCHEDULE
(
ID INT8 NOT NULL,
DAY VARCHAR(10),
DAY_NO VARCHAR(10),
APP_NAME VARCHAR(50),
APP_ID INT8,
PRIORITY INT,
STATE VARCHAR(30),
TIMEZONE VARCHAR(30),
TIME_FROM TIME,
TIME_TO TIME,
PRIMARY KEY (ID)
) [90079-200]
Location : db/migration/V1_0__CREATE_TABLE.sql (C:\Users\user\aac-core-orchestrator\target\classes\db\migration\V1_0__CREATE_TABLE.sql)
Line : 2
Statement : CREATE TABLE AAC_SCHEMA.SCHEDULE
(
ID INT8 NOT NULL,
DAY VARCHAR(10),
DAY_NO VARCHAR(10),
APP_NAME VARCHAR(50),
APP_ID INT8,
PRIORITY INT,
STATE VARCHAR(30),
TIMEZONE VARCHAR(30),
TIME_FROM TIME,
TIME_TO TIME,
PRIMARY KEY (ID)
)
这是应用程序-kube-acc.yml
spring:
cloud:
gcp:
credentials:
encoded-key:
xxxx
flyway:
baseline-on-migrate: false # change to true for first drop
enabled: false # change to true for first drop
schemas: aac_schema
datasource:
url: jdbc:postgresql://${DB_HOST}:5432/${DB_NAME}?currentSchema=aac_schema
username: ${DB_USER}
password: ${DB_PASSWORD}
driver-class-name: org.postgresql.Driver
initialization-mode: never
platform: postgresql
hikari:
maximum-pool-size: 50
auto-commit: true
schema: aac_schema
h2:
console:
enabled: false
# path: /console
jpa:
generate-ddl: false
show-sql: true
hibernate:
ddl-auto: none
properties:
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate:
jdbc:
batch_size: 100
lob:
non_contextual_creation: true
rabbitmq:
uri: amqp://test:[email protected]
host: xx.xx.xx.xx
username: test
password: xx
port: 15672
ssl:
enabled: false
resources:
static-locations: ${STATIC_LOCATION}
servlet:
multipart:
enabled: true
file-size-threshold: 2KB
max-file-size: 200MB
max-request-size: 215MB
mail:
host: smtp.gmail.com
port: 587
username: [email protected]
password: xx
properties:
mail:
smtp:
starttls:
enable: true
required: true
auth: true
connectiontimeout: true
timeout: 10000
writetimeout: 10000
jackson:
default-property-inclusion: non_null
server:
port: 8080
## DEFAULTS ##
logging:
level:
com.aac.core: DEBUG
com.aac.core.*: DEBUG
org.springframework: DEBUG
org.hibernate.SQL: TRACE
org.hibernate.type: TRACE
file: log/aac-core.log
security:
jwt:
client-id: client
client-secret: secret
grant-type: password
refresh-token: refresh_token
scope-read: read
scope-write: write
signing-key: sxx
运行/调试配置 环境变量:
DB_HOST=127.0.0.1;DB_NAME=postgres;DB_USER=postgres;DB_PASSWORD=root@123;spring.profiles.active=kube-acc
我尝试连接到实际的数据库,但我也得到了同样的错误。所以,我相信这不会是我的测试数据库的问题。
外壳是这里的罪魁祸首..问题描述中的模式图像显示“aac_schema”,而在脚本中显示“AAC_SCHEMA”。 PostgreSQL 中的模式名称区分大小写。希望有帮助:)