diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e38ccf5c..81187f4a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -88,7 +88,22 @@ jobs: with: distribution: 'temurin' java-version: '17' - # (5) Gradle build (Test 제외) + # (4.5) application.yml file 설정 + - name: Set yml file + uses: microsoft/variable-substitution@v1 + with: + files: ${{ env.RESOURCE_PATH }} + env: + spring.datasource.url: ${{ secrets.RDS_HOST }} + spring.datasource.username: ${{ secrets.RDS_USERNAME }} + spring.datasource.password: ${{ secrets.RDS_PASSWORD }} + secret.jwt-secret-key: ${{secrets.JWT_SECRET_KEY}} + secret.jwt-login-secret-key: ${{secrets.JWT_SECRET_KEY_1}} + secret.jwt-user-secret-key: ${{secrets.JWT_SECRET_KEY_2}} + secret.jwt-expired-in: ${{secrets.JWT_EXPIRED_IN}} + spring.datasource.driver-class-name: com.mysql.cj.jdbc.Driver + + # (5) Gradle build (Test 제외) - name: Build with Gradle uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee with: diff --git a/.gitignore b/.gitignore index c2065bc2..bbbc10b5 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,7 @@ out/ ### VS Code ### .vscode/ + +### application-local.yml ### +src/main/resource/application-local.yml +/**/application-local.yml \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9041d148..e9ec35e4 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' -// runtimeOnly 'com.mysql:mysql-connector-j' + runtimeOnly 'com.mysql:mysql-connector-j' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c7b96c06..964ed211 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,27 +1,93 @@ +spring: + profiles: + active: ${SPRING_PROFILES_ACTIVE:dev} + group: + "local": "localRDB, localMongoDB, localJPA, localPort, localSecret, web-mvc" + "dev": "devRDB, devMongoDB, devPort, devJPA, devSecret, web-mvc" + "prod": "devRDB, devMongoDB, devPort, prodJPA, devSecret, web-mvc" +--- +spring: + config: + activate: + on-profile: "devPort" server: port: 8080 - +--- spring: + config: + activate: + on-profile: "devRDB" + datasource: - url: ${DATASOURCE_URL_LOCAL} + url: ${DATASOURCE_URL} username: ${DATASOURCE_USERNAME} password: ${DATASOURCE_PASSWORD} - driver-class-name: ${DATASOURCE_DRIVER} + driver-class-name: jdbc:mysql://com.mysql.cj.jdbc.Driver +logging: + level: + org.hibernate.sql: debug +--- +spring: + config: + activate: + on-profile: "devMongoDB" + data: + mongodb: + uri: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${MONGO_DB} + +--- +spring: + config: + activate: + on-profile: "devJPA" jpa: hibernate: - ddl-auto: create # create : 존재하는 table을 전부 drop했다가 다시 생성 -> 테스트용 + ddl-auto: validate + properties: hibernate: format_sql: true show_sql: true +--- +spring: + config: + activate: + on-profile: "prodJPA" + + jpa: + hibernate: + ddl-auto: none + properties: + hibernate: + show_sql: false +--- +spring: + config: + activate: + on-profile: "devSecret" secret: - jwt-login-secret-key: ${JWT_LOGIN_SECRET_KEY} - jwt-user-space-secret-key: ${JWT_USER_SPACE_SECRET_KEY} - jwt-expired-in: ${JWT_EXPIRED_IN} + jwt-secret-key: ${JWT_SECRET_KEY} + jwt-login-secret-key: ${JWT_SECRET_KEY_LOGIN} + jwt-user-secret-key: ${JWT_SECRET_KEY_USER} + jwt-expired-in: ${JWT_EXPIRED_IN:3600000} +--- + +spring: + config: + activate: + on-profile: "web-mvc" + + mvc: + throw-exception-if-no-handler-found: true + + web: + resources: + add-mappings: false + + messages: + basename: errors + -logging: - level: - org.hibernate.sql: debug