Skip to content

Instantly share code, notes, and snippets.

@Leward
Created February 7, 2017 16:42
Show Gist options
  • Save Leward/38df62bed1644d1ebcdfc00c059bd5fb to your computer and use it in GitHub Desktop.
Save Leward/38df62bed1644d1ebcdfc00c059bd5fb to your computer and use it in GitHub Desktop.
springtrader-resource-server
package io.springtrader.resource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableResourceServer
@EnableDiscoveryClient
public class SpringtraderResourceServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringtraderResourceServerApplication.class, args);
}
@LoadBalanced
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
@Bean
InitializingBean init(RestOperations restOperations, RemoteTokenServices remoteTokenServices) {
return () -> remoteTokenServices.setRestTemplate(restOperations);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment