스프링 부트 버전 2.3.1 에서 H2 SQL 문법을 MySQL 문법으로 변경한 후 H2 콘솔 사용하는 방법
- 스프링 부트 버전: 2.3.1
- Gradle 버전: 6.4.1
스프링 부트 버전 2.3.1 에서 H2 SQL 문법을 MySQL 문법으로 변경한 후 H2 콘솔 사용하기 위해 Datasource를 설정해야 합니다.
1) application.properties 파일에 다음 내용을 추가합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# H2 설정
spring.h2.console.enabled=true
spring.h2.console.path=/h2
# Datasource 설정
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem://localhost/~/testdb;MODE=MYSQL
spring.datasource.username=sa
spring.datasource.password=
# sql 보기
spring.jpa.show_sql = true
# h2 문법을 mysql로 변경
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.dialect.storage_engine=innodb
spring.datasource.hikari.jdbc-url=jdbc:h2:mem://localhost/~/testdb;MODE=MYSQL
2) 콘솔 주소(localhost:8080/h2)에 접속한 후 [Connect] 버튼을 클릭합니다.
This post is licensed under
CC BY 4.0
by the author.

