小编aji*_*eng的帖子

springboot找不到feignclient

错误信息如下:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field helloAgent in com.example.client.controller.Hello required a bean of 
type 'com.example.common.agent.HelloAgent' that could not be found.

Action:

Consider defining a bean of type 'com.example.common.agent.HelloAgent' in 
your configuration.
Run Code Online (Sandbox Code Playgroud)

项目结构:

模块:test-client作为feignclient调用者。

模块:测试服务器作为feignclient接口的实现。

模块:test-common将所有feignclient放在一起。

常见测试:

package com.example.common.agent;
@FeignClient("hello")
public interface HelloAgent {
    @GetMapping("/hello")
    String hello(@RequestParam String msg);
}
Run Code Online (Sandbox Code Playgroud)

测试服务器:(工作正常)

package com.example.server.controller;

@RestController
public class Hello implements HelloAgent {
    @Override
    public String hello(@RequestParam String msg) {
        System.out.println("get " + msg);
        return "Hi " + msg;
    }
} …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-cloud spring-cloud-feign

1
推荐指数
1
解决办法
2827
查看次数