我正在将我的应用程序从 Spring Boot 1.4.x 迁移到 2.0.0。
在我们的开发环境中,我们在文件 db 上运行 H2,如下面的调试日志所示。我可以使用 ddl-auto: create with an in MEM db 运行该应用程序,但是当尝试针对我现有的 H2 文件工作时,我收到以下错误:
14:59:21.440 [] [] [main] DEBUG org.hibernate.loader.collection.plan.CollectionLoader - Static select for collection com.lmig.cortex.domain.entities.EmrProvisioning.associatedBuckets: select associated0_.emr_provisioning_id as emr_prov1_26_0_, associated0_.bucket_name as bucket_n2_26_0_, associated0_.is_ro as is_ro3_26_0_ from emr_associated_buckets associated0_ where associated0_.emr_provisioning_id=?
14:59:21.502 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension.............false
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit......................true
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - catalog.........................none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql...............none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery.............none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout...............30000
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource......................none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName.............none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties............{password=<masked>}
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................."org.h2.Driver"
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties...........{}
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry.............none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout.....................600000
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailFast..........true
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout.......1
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbc4ConnectionTest.............false
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl.........................jdbc:h2:file:~/API;FILE_LOCK=FS;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........0
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime.....................1800000
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize.................10
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry..................none
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory...........com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory@1da5c19d
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle.....................10
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - password........................<masked>
14:59:21.503 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - poolName........................"HikariPool-1"
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly........................false
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans..................false
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor...............none
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutorService........internal
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - schema..........................none
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory...................internal
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation............default
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - username........................"sa"
14:59:21.504 [] [] [main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout...............5000
14:59:21.504 [] [] [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
14:59:21.530 [] [] [main] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Failed to create/setup connection: Constraint "FK5FKLEKY5P9R43SW8TI8CRLYXG" already exists; SQL statement:
这是我的配置失败的样子:
datasource:
url: jdbc:h2:file:~/API;FILE_LOCK=FS;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL
driver-class-name: org.h2.Driver
username: sa
password:
continue-on-error: true
jpa:
database-platform: H2
hibernate:
ddl-auto: update
h2:
console:
enabled: true
附加信息:
我可以删除我的 h2 数据库文件,运行应用程序,它会生成新的数据库文件。一切都很好,我可以毫无问题地重新运行该应用程序。我删除了这些新文件,将旧文件移回。同样的问题。这些文件中是否有关于已执行操作/更新的元数据的位置?也许我可以调整它?