From 4207f8b9d6c3e5abe0e2137ffa38c336b2365496 Mon Sep 17 00:00:00 2001 From: Rebwon Date: Wed, 25 Aug 2021 15:29:43 +0900 Subject: [PATCH] Add: Database, Data Access Settings --- build.gradle | 5 ++++- .../infrastructure/DatabaseConfiguration.java | 18 ++++++++++++++++++ src/main/resources/application.properties | 1 - src/main/resources/application.yml | 2 ++ src/main/resources/mapper/xml/empty.txt | 0 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/yam/app/account/infrastructure/DatabaseConfiguration.java delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/mapper/xml/empty.txt diff --git a/build.gradle b/build.gradle index 0dfb054..09afd8c 100644 --- a/build.gradle +++ b/build.gradle @@ -37,10 +37,13 @@ dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' + implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0' + runtimeOnly 'com.h2database:h2' + implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-web' - testImplementation 'io.github.javaunit:autoparams:0.2.11' + testImplementation 'io.github.javaunit:autoparams:0.2.12' testImplementation 'com.tngtech.archunit:archunit-junit5:0.20.1' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/src/main/java/com/yam/app/account/infrastructure/DatabaseConfiguration.java b/src/main/java/com/yam/app/account/infrastructure/DatabaseConfiguration.java new file mode 100644 index 0000000..1150ac7 --- /dev/null +++ b/src/main/java/com/yam/app/account/infrastructure/DatabaseConfiguration.java @@ -0,0 +1,18 @@ +package com.yam.app.account.infrastructure; + +import javax.sql.DataSource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +@Configuration +public class DatabaseConfiguration { + + @Bean + public DataSource dataSource() { + return new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .build(); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..85dee64 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,2 @@ +mybatis: + mapper-locations: mapper/xml/*.xml diff --git a/src/main/resources/mapper/xml/empty.txt b/src/main/resources/mapper/xml/empty.txt new file mode 100644 index 0000000..e69de29