Skip to content

Commit

Permalink
feat: 환경변수 의존성 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
GiHwan2 committed Sep 28, 2024
1 parent 0c91630 commit 5c0ff06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ configurations {
}

repositories {
mavenCentral() // 기존 Maven Central 저장소
maven { url 'https://jitpack.io' } // JitPack 저장소 추가
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'mysql:mysql-connector-java:8.0.33'
implementation 'com.github.cdimascio:dotenv-spring-boot:2.2.0'
implementation 'io.github.cdimascio:dotenv-java:2.2.0'
// SpringDoc OpenAPI 의존성
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/goormthonUniv/floating/FloatingApplication.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
package goormthonUniv.floating;

import io.github.cdimascio.dotenv.Dotenv;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class FloatingApplication {

public static void main(String[] args) {
// .env 파일 로드
Dotenv dotenv = Dotenv.load();

// 환경 변수 읽기
String dbUrl = dotenv.get("DB_URL");
String dbUsername = dotenv.get("DB_USERNAME");
String dbPassword = dotenv.get("DB_PASSWORD");
String oauthClientId = dotenv.get("OAUTH_CLIENT_ID");
String oauthClientSecret = dotenv.get("OAUTH_CLIENT_SECRET");

// 환경 변수를 시스템에 설정 (필요한 경우)
System.setProperty("DB_URL", dbUrl);
System.setProperty("DB_USERNAME", dbUsername);
System.setProperty("DB_PASSWORD", dbPassword);
System.setProperty("OAUTH_CLIENT_ID", oauthClientId);
System.setProperty("OAUTH_CLIENT_SECRET", oauthClientSecret);

SpringApplication.run(FloatingApplication.class, args);

}

}

0 comments on commit 5c0ff06

Please sign in to comment.