使用WebClient调用RESTful Web服务

1.RESTFul web服务应用使用广泛

学习spring5 里面的webClient 通过它调用restful服务

目标 :搭建一个REST服务;简单例子为获取getMyName和获取第二个别名

2.src结构

3.运行效果

2020-01-27 23:12:44.480  INFO 59990 --- [           main] ExamRestful.RestfulApplication           : Starting RestfulApplication on appledeMacBook-Pro-3.local with PID 59990 (/Users/apple/learn/gs-reactive-rest-service/complete/build/classes/java/main started by apple in /Users/apple/learn/gs-reactive-rest-service/complete)
2020-01-27 23:12:44.486  INFO 59990 --- [           main] ExamRestful.RestfulApplication           : No active profile set, falling back to default profiles: default
2020-01-27 23:12:45.419  INFO 59990 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
2020-01-27 23:12:45.424  INFO 59990 --- [           main] ExamRestful.RestfulApplication           : Started RestfulApplication in 1.212 seconds (JVM running for 2.0)
>> result = Hello, keny
>> result2 = Hello, dachan

通webClient运行调用restfulweb服务


 

发布了141 篇原创文章 · 获赞 12 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/keny88888/article/details/104096528