diff --git a/backend/pirocheck/.gitignore b/backend/pirocheck/.gitignore index c2065bc..768f475 100644 --- a/backend/pirocheck/.gitignore +++ b/backend/pirocheck/.gitignore @@ -35,3 +35,6 @@ out/ ### VS Code ### .vscode/ + +### 환경 변수 ### +.env \ No newline at end of file diff --git a/backend/pirocheck/build.gradle b/backend/pirocheck/build.gradle index d57d42b..db75dba 100644 --- a/backend/pirocheck/build.gradle +++ b/backend/pirocheck/build.gradle @@ -29,6 +29,21 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + // REST API 사용을 위해 반드시 필요 + implementation 'org.springframework.boot:spring-boot-starter-web' + + // DTO에서 @Valid 사용 시 필요 + implementation 'org.springframework.boot:spring-boot-starter-validation' + + // PostgreSQL + runtimeOnly 'org.postgresql:postgresql' + + // 환경변수 관리 + implementation 'io.github.cdimascio:java-dotenv:5.2.2' + + // Swagger + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.6' } tasks.named('test') { diff --git a/backend/pirocheck/src/main/java/backend/pirocheck/PirocheckApplication.java b/backend/pirocheck/src/main/java/backend/pirocheck/PirocheckApplication.java index 96ad2c4..b7e39e5 100644 --- a/backend/pirocheck/src/main/java/backend/pirocheck/PirocheckApplication.java +++ b/backend/pirocheck/src/main/java/backend/pirocheck/PirocheckApplication.java @@ -2,11 +2,23 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import io.github.cdimascio.dotenv.Dotenv; @SpringBootApplication public class PirocheckApplication { public static void main(String[] args) { + + // .env 파일 로드 + Dotenv dotenv = Dotenv.configure() + .directory("./") // .env 파일 경로 설정 (기본: 프로젝트 루트) + .load(); + + // 환경변수를 시스템 프로퍼티에 추가 + dotenv.entries().forEach(entry -> + System.setProperty(entry.getKey(), entry.getValue()) + ); + SpringApplication.run(PirocheckApplication.class, args); } diff --git a/backend/pirocheck/src/main/resources/application.properties b/backend/pirocheck/src/main/resources/application.properties deleted file mode 100644 index 5aa603d..0000000 --- a/backend/pirocheck/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name=pirocheck diff --git a/backend/pirocheck/src/main/resources/application.yml b/backend/pirocheck/src/main/resources/application.yml new file mode 100644 index 0000000..656f19b --- /dev/null +++ b/backend/pirocheck/src/main/resources/application.yml @@ -0,0 +1,12 @@ +spring: + datasource: + url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} + username: ${DB_USER} + password: ${DB_PASSWORD} + jpa: + hibernate: + ddl-auto: update + show-sql: true + properties: + hibernate: + format_sql: true \ No newline at end of file