Spring Boot基礎教程16-使用SQL關係型數據庫-h2嵌入式數據庫的使用

嵌入式數據庫 
一、 添加依賴 
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</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;DB_CLOSE_ON_EXIT=FALSE
內存模式:
spring.datasource.url=jdbc:h2:mem:test
三、 進入控制檯 
路徑:http://localhost:8080/h2-console

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章