maven ํ๋ก์ ํธ์์ h2 ์คํ
maven ํ๋ก์ ํธ์์ h2 ์คํ
pom.xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
์คํ๋ง ๋ถํธ ์ด๋์
๋ผ์ด์ ๋ ๋ฒ์ ์ ๋ํ ์ค์ ์ด ์์ด ์์ ํํ๋ก dependency๋ฅผ ์์ฑํด ์ค๋ค.
๋ณด์์ ๋ํ ์ด์๊ฐ ์ถ๊ฐ๋ 1.4.198 ์ด์์ ๋ฒ์ ์ ์ถฉ๋์ด ์ผ์ด๋ ์ ์์ผ๋ฏ๋ก <version>1.4.197</version>
์ ์ถ๊ฐํด์ ๋ค์๊ณผ ๊ฐ์ด dependency๋ฅผ ์ค์ ํ์.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>runtime</scope>
</dependency>
application.yml or property
application.yml or property์ ๋ค์๊ณผ ๊ฐ์ด ์ถ๊ฐํด ์ค๋ค.
spring.datasource.url: jdbc:h2:mem:testdb
spring.datasource.driverClassName: org.h2.Driver
spring.datasource.username: sa
spring.datasource.password:
spring.jpa.database-platform: org.hibernate.dialect.H2Dialect
h2 ์ ์์ ๋ํ ๊ฒฝ๋ก์ ์ ๋ณด์ username, password, platform์ ์ค์ ์ด๋ค.
spring.jpa.hibernate.ddl-auto: create
์ถ๊ฐ๋ก ๋ค์๊ณผ ๊ฐ์ ์ค์ ์ผ๋ก ์๋ฒ ์์ ์ db ์์ฑ ์ฌ๋ถ๋ฅผ ์ค์ ํ ์ ์๋ค.update
๋ก ๋ณ๊ฒฝํ๋ฉด ์๋ฒ๊ฐ ๊บผ์ ธ๋ db์ ๋ฐ์ดํฐ๊ฐ ์์์ ์ผ๋ก ์ ์ฅ๋๋ค.
์ ์
์คํ๋ง ๋ถํธ ์๋ฒ๋ฅผ ์คํํ๊ณ url์ ๋ค์๊ณผ ๊ฐ์ด ์ ์ํ๋ค.
์์ ๊ฐ์ด ์
๋ ฅํ ๋ค Connect
๋ฅผ ๋๋ฌ์ค๋ค.
์ ์์ด ์๋ฃ๋จ์ ํ์ธํ ์ ์๋ค.