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. TableView载入WebView的一些小技巧 By 徐

    开发APP的时候,有时候会遇到服务器返回来的数据是一堆html内容,但是又不一定是完整的html ,可能只包含了主要内容,包括一些图片,文字等 然而我们处理带有html标签的数据时,用webview是 ...

  2. IDEA的使用和快捷键

    一.字体设置: 菜单:file->setting->Appearan 编辑区字体大小:file->setting->Font 字体加粗:file->setting-> ...

  3. LeetCode随缘刷题之无重复字符的最长子串

    欢迎评论区交流. package leetcode.day_12_04; /** * 给定一个字符串 s ,请你找出其中不含有重复字符的最长子串的长度. * <p> * 示例1: * &l ...

  4. puppeteerExamples

    What can I do? Most things that you can do manually in the browser can be done using Puppeteer! Here ...

  5. (一)什么是Rabbitmq

    1.初识MQ 1.1.同步和异步通讯 微服务间通讯有同步和异步两种方式: 同步通讯:就像打电话,需要实时响应. 异步通讯:就像发邮件,不需要马上回复. 两种方式各有优劣,打电话可以立即得到响应,但是你 ...

  6. CentOS7搭建ntp时钟服务器

    文章目录 服务器配置 远程客户端配置 服务器配置 # 关闭防火墙,selinux=disabled 1.# 服务器部署 [root@localhost ~]# yum -y install ntp n ...

  7. Dubbo源码剖析三之服务注册过程分析

    Dubbo源码剖析二之注册中心 - 池塘里洗澡的鸭子 - 博客园 (cnblogs.com)中对注册中心进行了简单的介绍,对Dubbo整合Zookeeper链接源码进行了详细分析.本文接着对服务注册过 ...

  8. 不知道这10个术语,你还敢说会JavaScript?

    每个行业,都有业内"行话",不了解这些行话的人,很难融入到行业中,也永远装不了逼. 从Curry到Closes,有很多JavaScript行话(该领域中使用的特殊词汇)知道这些行话 ...

  9. pyinstaller:各种错误及解决方法

    1.DLL load failed 说明没有找到某个DLL 解决方法: 在 D:\Anaconda\Anaconda3\Library\bin 下找到缺失的DLL,复制到dist下 2.No modu ...

  10. 含变量的字符串拼接(string.Format()或$"")

    含变量的字符串拼接,一般不要用 + 来连接字符串,可用以下两种方式: 一.string.Format() 二.$""  (在C#6以上的版本中可用,推荐这种写法) 1 public ...