How do I use spring.sql.init.schema-locations
Spring-boot version 2.5.3 failed

my spring.sql.inti.schema-locations and spring.datasource.schema

spring:
  sql:
    init:
      schema-locations: classpath:sql/create_table_h2.sql
  main:
    lazy-initialization: true # 开启懒加载,加快速度
    banner-mode: off # 单元测试,禁用 Banner
  # 数据源配置项
  datasource:
    url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;DB_CLOSE_DELAY=-1 # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写
    driver-class-name: org.h2.Driver
    username: sa
    password:
    druid:
      async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度
      initial-size: 1 # 单元测试,配置为 1,提升启动速度
#    schema: classpath:sql/create_table_h2.sql

  # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
  redis:
    host: 127.0.0.1 # 地址
    port: 16379 # 端口(单元测试,使用 16379 端口)
    database: 0 # 数据库索引

# MyBatisPlus配置
# https://baomidou.com/config/
mybatis-plus:
  # 不支持多包, 如有需要可在注解配置 或 提升扫包等级
  # 例如 com.**.**.mapper
  mapperPackage: com.ruoyi.**.mapper
  # 对应的 XML 文件位置
  mapperLocations: classpath*:mapper/**/*Mapper.xml
  # 实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: com.ruoyi.**.domain

spring-boot version 2.4.10 succeeded

spring.datasource.schema = classpath:sql/create_table_h2.sql
1

There are 1 answers

0
DAHUANGGO On

I think some other related factors may interfere with the project, or you can try to lower the version, which may be the best way. In projects with new features, I prefer to use spring-boot, which may be more Good way to upgrade.