Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package com.example.szconsumerservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;
public class SzConsumerServiceApplication {
RestOperations restOperations() {
return new RestTemplate();
public static void main(String[] args) {, args);
class ConsumerController {
private final RestOperations restOperations;
ConsumerController(RestOperations restOperations) {
this.restOperations = restOperations;
public String getGreeting() {"Logging GET request to /greet for " + this.getClass().toString());
return restOperations.getForObject("http://localhost:8080/hi", String.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.