我正在使用伪装客户端连接服务,但是当我尝试注入接口的依赖项时却出现错误消息。
目前,我正在做以下事情:-
1。使用Feign Client的自定义界面
@FeignClient(name="currency-exchange-service",url="localhost:8000")
public interface CurrencyExchangeServiceProxy {
@GetMapping("/currency-exchange/from/{from}/to/{to}")
public CurrencyConversionBean retrieveExchangeValue
(@PathVariable("from") String from,@PathVariable("to") String to);
}
2。配置类
@SpringBootApplication
@EnableFeignClients("com.learning.microservices.currencyconversionservice")
public class CurrencyConversionServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CurrencyConversionServiceApplication.class,args);
}
}
3。在控制器中注入Feign客户端接口(CurrencyExchangeServiceProxy)
@RestController
public class CurrencyConversionController {
@Autowired
private CurrencyExchangeServiceProxy proxy;
........
}
我遇到错误
Field proxy in com.learning.microservices.currencyconversionservice.CurrencyConversionController required a bean of type 'com.learning.microservices.currencyconversionservice.CurrencyExchangeServiceProxy' that could not be found.
The injection point has the following annotations: -
@org.springframework.beans.factory.annotation.Autowired(required=true)