springboot--h2 嵌入式数据库的使用

springboot–h2 嵌入式数据库的使用

  • springbooth2 嵌入式数据库的使用
    • 添加依赖
    • 配置
      • 指定路径
      • 内存模式
    • 进入控制台

添加依赖

<dependency>
<groupId>com.h2databasegroupId>
<artifactId>h2artifactId>
<scope>runtimescope>
dependency>

配置

spring.datasource.url=jdbc:h2:~/test;AUTO_SERVER=TRUE;DB_CLOSE
_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
  • 注: 1.”~”这个符号代表的就是当前登录到操作系统的用户对应的用户目录 2.账号密码我们指定之后,就会自动创建

========================================================

指定路径:

spring.datasource.url=jdbc:h2:file:D:/roncoo_h2/roncoo_spring_boot;AUTO_SERVER=TRUE;DBCLOSE_ON_EXIT=FALSE

内存模式:

spring.datasource.url=jdbc:h2:mem:test

进入控制台

路径:http://localhost:8080/h2-console

你可能感兴趣的:(springboot)