@RequestMapping("test")
@RestController
public class BookController {
@Autowired
RestTemplate restTemplate;
@RequestMapping("book")
public String book() {
return restTemplate.getForObject("http://localhost:8784/hello/world", String.class);
}
}
如上,SpringCloud可以通过ribbon+restTemplate去实现负载均衡,可网上所有的案例都是将restTemplate请求的路径写死的,我想知道,这个请求的路径,包括参数,可以动态的获取到吗?或者说,如果模块多微服务多的情况,这个路径该如何去写,求解