package com.test.controller;
import com.test.bean.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.util.Collection;
@RestController
@RequestMapping("/consumer")
public class StudentController {
@Autowired
private RestTemplate restTemplate;
@GetMapping("/findAll")
public Collection<Student> findAll(){
return restTemplate.getForEntity("http://localhost:8010/student/findAll", Collection.class).getBody();
}
@GetMapping("/findAll2")
public Collection<Student> findAll2(){
return restTemplate.getForObject("http://localhost:8010/student/findAll",Collection.class);
}
@GetMapping("/findById/{id}")
public Student findById(@PathVariable("id") long id){
return
restTemplate.getForEntity("http://localhost:8010/student/findById/{id}",Student.class,id).getBody();
}
@GetMapping("/findById2/{id}")
public Student findById2(@PathVariable("id") long id){
return restTemplate.getForObject("http://localhost:8010/student/findById/{id}",Student.class,id);
}
@PostMapping("/save")
public void save(@RequestBody Student student){
restTemplate.postForEntity("http://localhost:8010/student/save",student,null).getBody();
}
@PostMapping("/save2")
public void save2(@RequestBody Student student){
restTemplate.postForObject("http://localhost:8010/student/save",student,null);
}
@PutMapping("/update")
public void update(@RequestBody Student student){
restTemplate.put("http://localhost:8010/student/update",student);
}
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id") long id){
restTemplate.delete("http://localhost:8010/student/deleteById/{id}",id);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SpringCloud学习代码
共104个文件
class:28个
java:28个
yml:22个
需积分: 6 0 下载量 108 浏览量
2022-12-30
15:53:20
上传
评论
收藏 61KB RAR 举报
温馨提示
SpringCloud学习代码
资源推荐
资源详情
资源评论
收起资源包目录
SpringCloud学习代码 (104个子文件)
StudentController.class 3KB
StudentController.class 3KB
StudentController.class 2KB
Student.class 2KB
Student.class 2KB
Student.class 2KB
Student.class 2KB
Student.class 2KB
StudentServiceImpl.class 2KB
StudentController.class 1KB
FeignController.class 1KB
ConfigNativeController.class 1KB
RibbonApplication.class 1KB
RestTemplateApplication.class 984B
ConsumerApplication.class 972B
FeignApplication.class 943B
NativeConfigServerApplication.class 826B
EurekaServerApplication.class 816B
ZipkinController.class 812B
ZuulApplication.class 782B
ZipkinApplication.class 773B
NativeConfigClientApplication.class 759B
ZipkinClientApplication.class 741B
ProviderApplication2.class 732B
ProviderApplication.class 729B
FeignError.class 709B
FeignProviderClient.class 588B
StudentService.class 438B
.gitignore 184B
zipkin_server.iml 81B
Ribbon.iml 81B
feign.iml 81B
config_native.iml 81B
springcloud_test.iml 81B
StudentController.java 2KB
StudentController.java 2KB
StudentController.java 1KB
StudentServiceImpl.java 1019B
StudentController.java 867B
FeignController.java 775B
FeignApplication.java 614B
RibbonApplication.java 606B
ConfigNativeController.java 574B
RestTemplateApplication.java 532B
ConsumerApplication.java 526B
ZipkinController.java 511B
FeignProviderClient.java 497B
FeignError.java 447B
NativeConfigServerApplication.java 434B
EurekaServerApplication.java 431B
ZuulApplication.java 403B
ZipkinApplication.java 395B
NativeConfigClientApplication.java 345B
ZipkinClientApplication.java 333B
ProviderApplication2.java 328B
ProviderApplication.java 326B
StudentService.java 300B
Student.java 265B
Student.java 265B
Student.java 265B
Student.java 263B
Student.java 261B
eureka_server.kotlin_module 16B
.name 16B
uiDesigner.xml 9KB
workspace.xml 9KB
pom.xml 3KB
compiler.xml 2KB
pom.xml 2KB
encodings.xml 1KB
pom.xml 1KB
pom.xml 988B
jarRepositories.xml 864B
pom.xml 779B
pom.xml 777B
pom.xml 772B
pom.xml 770B
pom.xml 761B
pom.xml 761B
pom.xml 761B
misc.xml 526B
pom.xml 512B
application.yml 321B
application.yml 321B
application.yml 306B
application.yml 306B
application.yml 213B
application.yml 213B
application.yml 200B
application.yml 200B
application.yml 196B
application.yml 196B
application.yml 194B
application.yml 194B
application.yml 192B
application.yml 192B
application.yml 169B
application.yml 169B
bootstrap.yml 161B
bootstrap.yml 157B
共 104 条
- 1
- 2
资源评论
陌上小孩纸
- 粉丝: 16
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功