Spring Boot 2下导入依赖后使用Feign找不到@EnableFeignClients的解决办法

2023-05-16

文章目录

  • 解决方案
  • 详细解决步骤
    • 1. 导入依赖
    • 2. 引用注解
    • 3. 然后看一下maven是否引好
    • 4. 在pom依赖中加上代码
    • 5. maven看一下是否成功
    • 6. 使用注解
  • 完结撒花

解决方案

pom文件中这样引用

        <!-- feign依赖 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

	<!--导入-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

详细解决步骤

1. 导入依赖


        <!-- feign微服务调用 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

在这里插入图片描述

2. 引用注解

居然无效!!!
在这里插入图片描述

3. 然后看一下maven是否引好

在这里插入图片描述

4. 在pom依赖中加上代码

在官网上看到了解决方法

  <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

在这里插入图片描述

5. maven看一下是否成功

在这里插入图片描述

6. 使用注解

在这里插入图片描述

完结撒花

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Boot 2下导入依赖后使用Feign找不到@EnableFeignClients的解决办法 的相关文章

随机推荐