본문 바로가기

Develop/Springboot

springboot - application.yml 설정

[oauth2 google 관련 yml]

spring:
  security:
    oauth2:
      client:
        registration:
         google :
          client :
            client-id : [GCP 발급 ID]
            clientSecret: [GCP 발급 Secret key]
            accessTokenUri: https://www.googleapis.com/o/oauth2/token
            userAuthorizationUri: https://accounts.google.com/o/oauth2/auth
            clientAuthenticationScheme: form
            provider: github
            scope:
              - email
              - profile
          resource:
            userInfoUri: https://www.googleapis.com/oauth2/v2/userinfo

 client-id의 끝은 .apps.googleusercontent.com 이다.

 

[jpa및 db설정 관련 yml]

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://[서버 url]/[DB 스키마]?serverTimezone=UTC&characterEncoding=UTF-8
    username: root
    password:

  jpa:
    show-sql: true
    hibernate:
      format_sql: true
      ddl-auto: create
 
 logging:
  level:
    org:
      hibernate:
        SQL: DEBUG
        type:
          trace

 

[security관련 yml]

security:
  basic:
    enabled: false # security 기본 인증 옵션 제거

 

[내가 임의로 설정하는 yml]

test-propertiy:
  id: jyami
  secret: ajkflhjaskfhldfahjklfbdn

사용법

@Component
@Getter
@Setter
@ConfigurationProperties(prefix = "test-property")
public class TokenConfig {
    private String id;
    private String secret;
}