Update: T05/搭建service-consumer模块
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package cn.hezhaohui.serviceconsumer.controller;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class ConsumeController {
|
||||
|
||||
@Resource
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@GetMapping("/print")
|
||||
public String print() {
|
||||
String number = restTemplate.getForObject("http://service-producer/api/number", String.class);
|
||||
return "[Generate]: " + number;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user