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. android TextView属性详解

    RelativeLayout用到的一些重要的属性: 第一类:属性值为true或false     android:layout_centerHrizontal  水平居中      android:l ...

  2. Haproxy配合Nginx搭建Web集群部署

    Haproxy配合Nginx搭建Web集群部署实验 1.Haproxy介绍 2.Haproxy搭建 Web 群集 1.Haproxy介绍: a)常见的Web集群调度器: 目前常见的Web集群调度器分为 ...

  3. Solon 1.6.21 发布,轻量级应用开发框架

    关于官网 千呼万唤始出来: https://solon.noear.org .整了一个月多了...还得不断接着整! 关于 Solon Solon 是一个轻量级应用开发框架.支持 Web.Data.Jo ...

  4. Java泛型详解,史上最全图文详解!

    泛型在java中有很重要的地位,无论是开源框架还是JDK源码都能看到它. 毫不夸张的说,泛型是通用设计上必不可少的元素,所以真正理解与正确使用泛型,是一门必修课. 一:泛型本质 Java 泛型(gen ...

  5. Solution -「LOCAL」逃生

    \(\mathcal{Description}\)   有 \(n\) 个人掉进了深度为 \(h\) 的坑里,第 \(i\) 个人的肩高为 \(a_i\),臂长为 \(b_i\).设当前坑里人的集合为 ...

  6. Vue2.0源码学习(4) - 合并配置

    合并配置 通过之前的源码学习,我们已经了解到了new Vue主要有两种场景,第一种就是在外部主动调用new Vue创建一个实例,第二个就是代码内部创建子组件的时候自行创建一个new Vue实例.但是无 ...

  7. Linux-CPU优化之上下文切换

    为什么大量进程(通常进程数大于CPU个数)的运行会导致CPU长时间处于等待时间而导致平均负债率过高呢?没有使用CPU且无不可中断的进程,这就涉及到了上下文切换. 巧妙地利用了时间片轮转的方式, CPU ...

  8. CPU平均负载率之stress模拟CPU密集型进程

    一.对CPU密集型进程进行模拟,具体如下: 第一个终端 在第一个终端运行 stress 命令,模拟一个 CPU 使用率 100% 的场景:stress --cpu 1 -- timeout 600 第 ...

  9. Nginx安装启用

    安装版本为1.17.8. 1.安装Nginx依赖, pcre. openssl. gcc. zlib(推荐使⽤yum源⾃动安装) yum -y install gcc zlib zlib-devel ...

  10. ESP32-S3 arduino 开发环境搭建

    ESP32-S3 arduino 简要描述 在github上搜索arduino-esp32,找到并打开espressif/arduino-esp32仓库,从master主分支切换到esp32-s3-s ...