【SpringBoot】RestTemplate调用报错:'org.springframework.web.client.RestTemplate' that could not be found.
来源:互联网 发布:22周排畸b超数据看男女 编辑:程序博客网 时间:2024/05/21 06:58
RestTemplate引入方式为:
@Autowired
public RestTemplate restTemplate;
时报错,错误信息如下
错误:'org.springframework.web.client.RestTemplate' that could not be found.
改为:
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
String providerMsg = restTemplate().getForEntity("http://localhost:8009/ecif-business/PrpObject/test",String.class).getBody();
System.out.println("Hello,Customer! msg from provider : <br/><br/> " + providerMsg);;
后即正确
此种方式为Spring Boot<=1.3时使用的,在>=1.4版本后,可以通过RestTemplateBuilder来使用。
@Autowired
public RestTemplate restTemplate;
时报错,错误信息如下
错误:'org.springframework.web.client.RestTemplate' that could not be found.
改为:
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
String providerMsg = restTemplate().getForEntity("http://localhost:8009/ecif-business/PrpObject/test",String.class).getBody();
System.out.println("Hello,Customer! msg from provider : <br/><br/> " + providerMsg);;
后即正确
此种方式为Spring Boot<=1.3时使用的,在>=1.4版本后,可以通过RestTemplateBuilder来使用。
阅读全文
0 0
- 【SpringBoot】RestTemplate调用报错:'org.springframework.web.client.RestTemplate' that could not be found.
- NoClassDefFoundError: Could not initialize class org.springframework.web.client.RestTemplate
- Spring org.springframework.web.client.RestTemplate乱码
- com.springframework.web.client.RestTemplate
- 记录org.springframework.web.client.RestTemplate的用法
- org.springframework.web.client.RestTemplate post 表单提交
- springboot 报错Field XXX required a bean of type XXX that could not be found.
- Spring Web Client# RestTemplate
- springboot-restTemplate
- Db2 client上load from cursor报错SQL1013N The database name .. could not be found
- RestTemplate报错:no suitable HttpMessageConverter found for request type
- springmvc+fileuploader上传报错 Could not instantiate bean class [org.springframework.web.multipart.Multi
- RestTemplate 调用
- 不能自动装配RestTemplate,not found
- required a bean of type 'org.hibernate.SessionFactory' that could not be found.
- WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
- log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
- log4j:WARN No appenders could be found for logger (org.springframework.web.context
- Date与LocalDateTime、LocalDate、LocalTime互转
- 丘成桐在CNCC会议的演讲全文
- 程序员,30岁,如何趁 AI 浪潮突破年薪天花板?
- 为什么Java开发人员都带眼镜 | 程序员搞笑段子合集
- ofbiz——上传工具类HttpRequestFileUpload修改优化
- 【SpringBoot】RestTemplate调用报错:'org.springframework.web.client.RestTemplate' that could not be found.
- 自定义view画圆跟着鼠标移动
- 圆2
- css样式继承体现&&盒模型分析&&BFC&&clearfix
- C++中#if #ifdef 的作用
- 一行代码解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10
- 图片上传时input file change事件多次触发解决
- c++ List容器
- 野指针,指向常量的指针,指针常量