● Spring boot에 H2DB Dependency 추가
1. 아래 링크로 h2db 사이트의 maven dependency 확인
http://h2database.com/html/build.html?highlight=maven&search=maven#maven2
Build
Build Portability Environment Building the Software Using Maven 2 Using Eclipse Translating Submitting Source Code Changes Reporting Problems or Requests Automated Build Generating Railroad Diagrams Portability This database is written in Java and there
h2database.com
2. pom.xml에 다음을 추가
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>
3. application.yml 파일에 다음과 같이 추가
##h2.console 은 h2db 콘솔 화면에 접속이 가능하게 해주는 설정
spring:
h2:
console:
enabled: true
path: /h2-console
datasource:
driverClassName: org.h2.Driver
#url: jdbc:h2:file:./target/h2db/db/application;DB_CLOSE_DELAY=-1
url: jdbc:h2:mem:testdb
username: sa
password:
4. 프로젝트 실행 후 콘솔 접속
url =====> http://localhost:8080/h2-console
application.yml 에 적었던 설정대로 h2-console 화면에도 입력
5. 접속 확인
'Spring Boot' 카테고리의 다른 글
[Spring Boot] Mybatis Sample (0) | 2022.02.05 |
---|---|
[spring boot] JPA sample (0) | 2022.02.04 |
[Spring boot] SQL script 를 활용한 DB 초기화 (0) | 2022.02.03 |
[Spring Boot] profiles 변경 (0) | 2022.02.02 |
[Spring Boot] 프로젝트 생성 및 시작하기 (Visual Studio Code) (0) | 2021.09.18 |