From 48409430a9a4439263622541bb02b0416f7ca031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=EC=9B=90?= Date: Sun, 21 Jul 2024 14:54:02 +0900 Subject: [PATCH] =?UTF-8?q?Chore:=20Springboot=20web,=20jpa,=20lombok=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Chore: DB 연결 정보를 application.yml에 추가 * Chore: web, jpa, postgresql, lombok 의존성 추가 * Chore: env example 파일 추가 * Chore: testcontainers 테스트 환경 설정 추가 --- .gitignore | 1 + build.gradle.kts | 17 +++++++++++++++ src/main/resources/.env.example | 5 +++++ src/main/resources/application.properties | 1 - src/main/resources/application.yml | 25 +++++++++++++++++++++++ src/test/resources/application.yml | 11 ++++++++++ 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/.env.example delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml create mode 100644 src/test/resources/application.yml diff --git a/.gitignore b/.gitignore index 3b191483..990eb61c 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ out/ **/resources/.env **/resources/.env.* +!**/resources/.env.example diff --git a/build.gradle.kts b/build.gradle.kts index 8ba79165..88856e5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,23 @@ repositories { dependencies { implementation("org.springframework.boot:spring-boot-starter") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-data-jpa") + implementation("org.springframework.boot:spring-boot-starter-validation") + implementation("org.postgresql:postgresql:42.7.3") + implementation("me.paulschwarz:spring-dotenv:4.0.0") + + // Lombok + annotationProcessor("org.projectlombok:lombok:1.18.34") + testCompileOnly("org.projectlombok:lombok:1.18.34") + testAnnotationProcessor("org.projectlombok:lombok:1.18.34") + + // testcontainers + testImplementation("org.testcontainers:testcontainers:1.20.0") + testImplementation("org.testcontainers:junit-jupiter:1.20.0") + testImplementation("org.testcontainers:jdbc:1.20.0") + testImplementation("org.testcontainers:postgresql:1.20.0") + testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/src/main/resources/.env.example b/src/main/resources/.env.example new file mode 100644 index 00000000..c3ff71d6 --- /dev/null +++ b/src/main/resources/.env.example @@ -0,0 +1,5 @@ +DATABASE_HOST= +DATABASE_PORT= +DATABASE_NAME= +DATABASE_USER= +DATABASE_PASSWORD= diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 22ca8c47..00000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name= run-us diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..9d053821 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,25 @@ +spring.application.name: run-us + +spring: + jpa: + hibernate: + ddl-auto: none + show-sql: true + open-in-view: false + + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} + username: ${DATABASE_USER} + password: ${DATABASE_PASSWORD} + +--- +spring.config.activate.on-profile: local + +spring: + jpa: + hibernate: + ddl-auto: update + +--- +spring.config.activate.on-profile: prod diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 00000000..0ff7be5a --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,11 @@ +spring: + jpa: + hibernate: + ddl-auto: create + show-sql: true + open-in-view: false + defer-datasource-initialization: true + + datasource: + driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver + url: jdbc:tc:postgresql:16.3://test