springboot h2數據庫的配置


配置文件

  #h2 數據庫配置

#配置數據庫連接地址
spring.datasource.url=jdbc:h2:sunniwell:sos
#配置數據庫驅動
spring.datasource.driver-class-name=org.h2.Driver
#配置數據庫用戶名
spring.datasource.username=root
#配置數據庫密碼
spring.datasource.password=sunniwell
#配置能遠程訪問
spring.h2.console.settings.web-allow-others=true
#配置訪問地址
spring.h2.console.path=/h2-console
#配置項目啟動 h2就啟動
spring.h2.console.enabled=true
#進行該配置后,每次啟動程序,程序都會運行resources/db/schema.sql文件,對數據庫的結構進行操作。
#spring.datasource.schema=classpath:db/schema.sql
#進行該配置后,每次啟動程序,程序都會運行resources/db/data.sql文件,對數據庫的數據操作。
#spring.datasource.data=classpath:db/data.sql

 

 

pom.xml

 

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>



H2數據庫介紹

常用的開源數據庫:H2,Derby,HSQLDB,MySQL,PostgreSQL。其中H2,HSQLDB類似,十分適合作為嵌入式數據庫使用,其它的數據庫大部分都需要安裝獨立的客戶端和服務器端。
H2的優勢:
1、h2采用純Java編寫,因此不受平台的限制。
2、h2只有一個jar文件,十分適合作為嵌入式數據庫試用。
3、性能和功能的優勢

H2比HSQLDB的最大的優勢就是h2提供了一個十分方便的web控制台用於操作和管理數據庫內容,這點比起HSQLDB的swing和awt控制台實在好用多了。






免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM