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 异常的更多相关文章

  1. SpringCloud报错:Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing MappingNode

    今天在配置eureka集群时,SpringCloud报错如下: Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing ...

  2. SpringCloud报错:Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

    今天启动用eureka的服务消费者时,一直出现问题. SpringCloud报错: Caused by: org.springframework.context.ApplicationContextE ...

  3. 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 ...

  4. 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法

    首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...

  5. 解决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 ...

  6. 自动化上传图片,路径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 ...

  7. input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'

    今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...

  8. Springcloud报错:java.lang.IllegalStateException: Service id not legal hostname (/a-service)

    今天在做springcloud链路追踪的时候,报错java.lang.IllegalStateException: Service id not legal hostname (/a-service) ...

  9. springcloud报错集合

    springcloud启动报错Connection refused: connect 参考:https://blog.csdn.net/deemo__/article/details/78932401 ...

随机推荐

  1. docker | jenkins 实现自动化部署项目,后端躺着把运维的钱挣了!(上)

    前言 背景 最近在帮学校导师写项目,团队有4个人,项目前后端分离.如果是选择瀑布式开发:(在约定好接口的情况下)A.B同学写前端,C.D同学写后端,然后约定一个时间统一联调,最后将项目交付安装到客户机 ...

  2. rabbitmq集群实现

    官方文档 一.环境准备 1.1 IP地址规划 1.2 配置主机域名解析 ##每个节点修改主机名 # hostnamectl set-hostname mq1.example.local # hostn ...

  3. 有手就行7——*项目构建细节2-钩子(webhook) 配置

    有手就行7--*项目构建细节2-钩子(webhook) 配置 钩子服务  1)开启webhook功能 使用root账户登录到后台,点击Admin Area -> Settings -> N ...

  4. tarjan2

    反过来调过去,我还是感觉没学明白缩点 讲一个有向图中的所有强连通分量缩成一个点后,构成的新图是一个DAG. 一个点所在的强连通分量一定被该点所在DFS搜索树所包含 树上的边大致分为:树枝边,前向边(从 ...

  5. find+grep+正则表达式

    目录 find+grep+正则表达式 1.find 2.grep 3.正则表达式 find+grep+正则表达式 1.find 根据文件的名称或者属性查找文件. # 自己在 /root/adc目录下长 ...

  6. 对于计算正确率时 logits.argmax(dim=1),torch.eq(pre_label,label)

    额  好像是一句非常简单的代码 ,但是作为新手 ,我是完全看不懂哎 前十眼. 首先 这里的logits是一个 (a,b)维的张量.其中a是你的全连接输出维度,b是一个batch中的样本数量. 我们经过 ...

  7. smbms项目核心功能实现

    SMBMS 数据库: 项目如何搭建? 考虑使用不使用Maven?依赖,Jar 1.项目搭建准备工作 搭建一个maven web项目 配置Tomcat 测试项目是否能够跑起来 导入项目中会遇到的jar包 ...

  8. 计算机网络-IP篇

    目录 IP 基本认识 IP地址 IP 地址的分类 公有 IP 地址与私有 IP 地址 IP 地址与路由控制 IP 分⽚与重组 IPv6 基本认识 IPv4 ⾸部与 IPv6 ⾸部 IP协议 DNS A ...

  9. Linux主机内存评估手册-从零到无

    --时间:2020年10月22日 --作者:飞翔的小胖猪 文档基于Centos Linux操作系统作为生产服务器运行环境.实时的查看分析当前系统内存的使用情况是否存在内存瓶颈,结合应用及现行业务需求分 ...

  10. Mac下的平铺式桌面 - Yabai

    Mac下的平铺式桌面 - Yabai 近来无事,凑着周末休息的时间,想折腾一下 Mac.很久之前就有朋友给我推荐过一款名为"Yabai"的平铺式桌面管理软件,今天,就折腾起来了. ...