weixin_44450111
BDTH-
采纳率0%
2019-09-20 14:42 阅读 1.7k

已经依赖Ribbon的jar包,但是@LoadBalanced还是标红报错不能使用, 为什么?

@Configuration
public class ConfigBean {
@LoadBalanced //这里报错
@Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
}
}

`<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

com.bgg.springCloud
springCloud
1.0-SNAPSHOT
<!-- lookup parent from repository -->

<artifactId>consumer-8091</artifactId>
<description>部门微服务消费者</description>
<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency><!-- 自己定义的api -->
        <groupId>com.bgg.springCloud</groupId>
        <artifactId>test-api</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Ribbon相关 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-ribbon</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>


    <!-- 修改后立即生效,热部署 -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>springloaded</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
</dependencies>


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐