springcloud报错-Ribbon整合Eureka,出现 No instances available for XXX 异常
RestTemplate注入有问题
新版的需要这样注入:
@Bean
@LoadBalanced
RestOperations restTemplate(RestTemplateBuilder builder) {
return builder.build();
} @Autowired
RestOperations restTemplate;
package com.csi.order; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate; @SpringBootApplication
public class OrderApplication {
// 旧版不支持
// @Bean
// @LoadBalanced
//
// public RestTemplate restTemplate(){
// return new RestTemplate();
// } @Bean
@LoadBalanced
RestOperations restTemplate(RestTemplateBuilder builder) {
return builder.build();
} public static void main(String[] args) {
SpringApplication.run(OrderApplication.class,args);
}
}
// controller 里
@Autowired
RestOperations restTemplate;
springcloud报错-Ribbon整合Eureka,出现 No instances available for XXX 异常的更多相关文章
- SpringCloud报错:Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing MappingNode
今天在配置eureka集群时,SpringCloud报错如下: Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing ...
- SpringCloud报错:Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
今天启动用eureka的服务消费者时,一直出现问题. SpringCloud报错: Caused by: org.springframework.context.ApplicationContextE ...
- SpringCloud报错: "Field discoveryClient in com.controller.DcController required a bean of type 'com.netflix.discovery.DiscoveryClient' that could not be found."
SpringCloud报错: "Field discoveryClient in com.controller.DcController required a bean of type 'c ...
- 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法
首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...
- 解决xcode10打包报错:That command depends on command in Target ‘xxx’:scrpit phase"[CP] Copy Pods Resources"
问题:使用xcode10打包报错,提示 error:Multiple commands produce ‘xxxx/xxx.app’ 1)Target ‘xx’ has create director ...
- 自动化上传图片,路径driver.find_element_by_id("oper-img-change").send_keys("C:\\Users\\76776\\Pictures\\logo.jpg"),为正确姿势,单\报错 'unicodeescape' codec can't decode bytes in position XXX: trun
自动化上传图片,路径driver.find_element_by_id("oper-img-change").send_keys("C:\\Users\\76776\\P ...
- input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'
今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...
- Springcloud报错:java.lang.IllegalStateException: Service id not legal hostname (/a-service)
今天在做springcloud链路追踪的时候,报错java.lang.IllegalStateException: Service id not legal hostname (/a-service) ...
- springcloud报错集合
springcloud启动报错Connection refused: connect 参考:https://blog.csdn.net/deemo__/article/details/78932401 ...
随机推荐
- 【BZOJ2820】YY的GCD(莫比乌斯反演 数论分块)
题目链接 大意 给定多组\(N\),\(M\),求\(1\le x\le N,1\le y\le M\)并且\(Gcd(x, y)\)为质数的\((x, y)\)有多少对. 思路 我们设\(f(i)\ ...
- 统计学习:逻辑回归与交叉熵损失(Pytorch实现)
1. Logistic 分布和对率回归 监督学习的模型可以是概率模型或非概率模型,由条件概率分布\(P(Y|\bm{X})\)或决 策函数(decision function)\(Y=f(\bm{X} ...
- Python篇函数总结【输出函数】
1.raw_input("\n\nPress the enter key to exit.") 以上代码中 ,"\n\n"在结果输出前会输出两个新的空行.一旦用 ...
- 一文说透https中的s是什么?
一.HTTP 与 HTTPS 有哪些区别? 1. HTTP 是超文本传输协议,信息是明文传输,存在安全风险.HTTPS ,是在 TCP 和网络层之间加入了 SSL/TLS 安全协议,也就是安全套接字层 ...
- Solution -「APIO/CTSC 2007」「洛谷 P3620」数据备份
\(\mathcal{Description}\) Link. 给定升序序列 \(\{x_n\}\) 以及整数 \(k\),在 \(\{x_n\}\) 中选出恰 \(k\) 对 \((x_i, ...
- C#设置进程PATH环境变量值解决某些Win32DLL找不到路径问题
C#.NET通过设置当前进程PATH环境变量值解决某些Win32DLL找不到路径问题 以下函数设置PATH环境变量值(请注意:该环境变量为当前进程的环境变量,非系统环境变量)用于解决在调用某些Win3 ...
- etcdserver: mvcc: database space exceeded
文章目录 查看节点状态 获取旧版本号 压缩旧版本 清理碎片 再次查看节点状态 清楚告警 k8s的apiserver组件重启失败,通过journalctl -xeu kube-apiserver命令查看 ...
- ELK-EFK-v7.12.0日志平台部署
ELK和EFK是什么 ELK和EFK是四个开源产品的组合: Elasticsearch 一个基于Lucene搜索引擎的NoSQL数据库 Logstatsh 一个日志管道工具,接受数据输入,执行数据转换 ...
- python的import语句
1.import作用 import跟C/C++中的#include作用有点类似,都是为了调用定义在其他文件中的变量.函数或者类,但实现的区别很大. C/C++中如果a.cpp include了b.h那 ...
- 开源爱好者月刊《HelloGitHub》第 71 期
兴趣是最好的老师,HelloGitHub 让你对编程感兴趣! 简介 HelloGitHub 分享 GitHub 上有趣.入门级的开源项目. https://github.com/521xueweiha ...