0
我要去飛行用分貝遷移添加到現有項目具有以下CONFIGS:
- 項目類型:春季啓動
- DB:MariaDB的
應用local.yaml(遷飛和數據源CONFIGS):
...
flyway:
enabled: true
locations: classpath:db.migration
baselineOnMigrate: true
spring:
jackson:
serialization:
indent_output: true
devtools:
restart:
enabled: false
livereload:
enabled: false
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mariadb://localhost:3306/migration
username: root
password: testing1
hikari:
data-source-properties:
leakDetectionThreshold: 2000
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
jpa:
database-platform: org.hibernate.dialect.MySQL5Dialect
database: MYSQL
show-sql: false
hibernate.id.new_generator_mappings: true
properties:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
hibernate.hbm2ddl.import_files: schema-mysql.sql
hibernate.hbm2ddl.import_files_sql_extractor: org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
open-in-view: false
hibernate:
ddl-auto: create-drop
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
...
問題:
當應用程序停止時,數據庫表中不掉線。但正如我使用ddl-auto: create-drop
,它預計表將被刪除。
注意:我知道使用Flyway對於易失性數據庫似乎有點奇怪。由於有些配置類在啓動時插入初始數據。如果在應用程序已停止該數據庫也不會落下,它會拿出抱怨[例如: - 唯一約束衝突]在接下來的啓動,因爲初始值已插入。
我會很感激,如果有人能幫助我與他們的真正解決方案。