Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 应用程序停止时放置表格时的Flyway问题_Java_Spring Boot_Gradle_Mariadb_Flyway - Fatal编程技术网

Java 应用程序停止时放置表格时的Flyway问题

Java 应用程序停止时放置表格时的Flyway问题,java,spring-boot,gradle,mariadb,flyway,Java,Spring Boot,Gradle,Mariadb,Flyway,概述 我将使用以下配置将flyway db迁移添加到现有项目中: ... flyway: enabled: true locations: classpath:db.migration baselineOnMigrate: true spring: jackson: serialization: indent_output: true devto

概述

我将使用以下配置将flyway db迁移添加到现有项目中:

    ...

    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
    ...
  • 项目类型:Spring Boot
  • DB:MariaDB
application-local.yaml(Flyway和数据源配置):

问题:

当应用程序停止时,不会删除db表。但当我使用
ddl auto:createdrop
时,它应该被删除

注意:我知道对volatile DB使用Flyway似乎有点奇怪。因为有一些配置类可以在启动时插入初始数据。如果数据库在应用程序停止时没有被删除,它将在下一次启动时出现投诉[例如:唯一约束冲突],因为初始值已经插入

如果有人能帮助我找到他们真正的解决方案,我将不胜感激。

美国:

删除架构并在SessionFactory启动时重新创建它。此外,在SessionFactory关闭时删除架构

你如何停止你的申请?我猜当您停止应用程序时,您并没有关闭
SessionFactory

也许您需要将
/shutdown
端点添加到
spring boot
应用程序中,以正常关闭应用程序