标签:ica source stat 消费者 str static oca ble turn
服务提供】provide:8080端口
@RestController
@RequestMapping("sysUserWeb2")
public class SysUserWeb2 {
@Resource
private SysUserService2 SysUserService2;
@RequestMapping("/getAll")
@ResponseBody
public List<SysUser>findAll2(){
return SysUserService2.findAll2();
}
@RequestMapping("/findSysUserName")
@ResponseBody
public SysUser findSysUserName(String name){
return SysUserService2.findSysUserName(name);
}
}
【服务消费】customer :8081端口
@RestController
public class Controller {
@Autowired
private RestTemplate restTemplate;
@GetMapping("/findSysUserName/{name}")
public SysUser findSysUserName(@PathVariable String name){
return restTemplate.getForObject("http://localhost:8080/sysUserWeb2/findSysUserName?name="+name,
SysUser.class);
}
}
启动类
@SpringBootApplication
public class SpringBooTemplateApplication {
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(SpringBootTemplateApplication.class, args);
}
}
标签:ica source stat 消费者 str static oca ble turn
原文地址:https://www.cnblogs.com/yuanhailiang/p/8799351.html