优点:
缺点:
1.引入内置的H2数据库
因为我想做到使用H2直接启动项目,所以scope设置为runtime,如果仅用H2做测试用的话,请设置成test
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>runtime</scope>
- </dependency>
-
2.yml文件内数据库的配置,改成H2
- # 数据源配置
- spring:
- datasource:
- # 驱动
- driver-class-name: org.h2.Driver
- # h2 内存数据库 内存模式连接配置 库名: agileboot
- url: jdbc:h2:mem:agileboot;DB_CLOSE_DELAY=-1
- h2:
- # 开启console 访问 默认false
- console:
- enabled: true
- settings:
- # 开启h2 console 跟踪 方便调试 默认 false
- trace: true
- # 允许console 远程访问 默认false
- web-allow-others: true
- # h2 访问路径上下文
- path: /h2-console
-
- sql:
- init:
- platform: mysql
- # 初始化数据
- schema-locations: classpath:h2sql/agileboot_schema.sql
- data-locations: classpath:h2sql/agileboot_data.sq