원본 본문으로 이동하기

Spring .yml (YAML) 기본설정방법

박용서 - 스프링 시큐리티 OAUTH 강의에서 이부분을 설명하지 프로퍼티로 처리했는데 추가로 달아봅니다. YAML - https://gs.saro.me/#!m=pd&pn=77 @Bean public static PropertySourcesPlaceholderConfigurer properties() { PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer(); YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean(); yaml.setResources(new ClassPathResource("classpath로부터경로주소.yml")); propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject()); return propertySourcesPlaceholderConfigurer; } 예제 - https://gs.saro.me/#!m=elec&jn=835 중.. @Bean @ConfigurationProperties("facebook.client") AuthorizationCodeResourceDetails facebook() { return new AuthorizationCodeResourceDetails(); } @Bean @ConfigurationProperties("facebook.resource") ResourceServerProperties facebookResource() { return new ResourceServerProperties(); } 프로퍼티 방식 facebook.client.clientId: 발급받은 클라이언트 아이디 facebook.client.clientSecret: 발급받은 시크릿 키 facebook.client.accessTokenUri: https://graph.facebook.com/oauth/access_token facebook.client.userAuthorizationUri: https://www.facebook.com/dialog/oauth facebook.client.tokenName: oauth_token facebook.client.authenticationScheme: query facebook.client.clientAuthenticationScheme: form facebook.client.scope: public_profile,email,user_birthday facebook.resource.userInfoUri: https://graph.facebook.com/me YAML 방식 facebook: client: clientId: 발급받은 클라이언트 아이디 clientSecret: 발급받은 시크릿 키 accessTokenUri: https://graph.facebook.com/oauth/access_token userAuthorizationUri: https://www.facebook.com/dialog/oauth tokenName: oauth_token authenticationScheme: query clientAuthenticationScheme: form scope: public_profile,email,user_birthday resource: userInfoUri: https://graph.facebook.com/me 추신 워낙 단순한거라 강의로 쓸게 없어서 이렇게 써봅니다... - 스프링 자바