pom.xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- h2的控制台需要用到web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
yml
spring:
#任意ROM架構
jpa:
show-sql: true
h2:
console: #開啟控制台
enabled: true
path: /h2
然後啟動
可以看到SpringBoot自動配置
資料庫的連接配接是"jdbc:h2:mem:0900bc9a-962c-4140-99b3-74034d196632"
然後通路頁面 http://127.0.0.1:8080/h2