본문 바로가기

Dev/Spring Boot

Maven Spring boot h2 데이터베이스 연결

application.yml

server:
  port: 8080
spring:
  h2:
    console:
      enabled: true
      path: /h2-console
  datasource:
    url: jdbc:h2:~/test
    username: sa
    password: 1234
    driver-class-name: org.h2.Driver

 

pom.xml

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
	<groupId>com.h2database</groupId>
	<artifactId>h2</artifactId>
	<scope>runtime</scope>
</dependency>

 

localhost:8080/h2-console 접속

 

 

참고

https://youngjinmo.github.io/2020/03/h2-database/