rosettapebble

Untitled

Jun 30th, 2021
19
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package app2;
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.cloud.client.loadbalancer.LoadBalanced;
  5. import org.springframework.web.bind.annotation.GetMapping;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import org.springframework.web.client.RestTemplate;
  8.  
  9. @RestController
  10. public class App2Controller {
  11. // @Autowired
  12. @LoadBalanced
  13. RestTemplate restTemplate = new RestTemplate();
  14.  
  15. @GetMapping("/callapp2")
  16. public void sayHello() {
  17. String response = restTemplate.getForObject("http://APP1/user", String.class);
  18. System.out.println("callapi2 response = "+ response);
  19. }
  20. }
  21.  
RAW Paste Data