Error : Field proxy in com.project.currencyconversionservice.CurrencyConversionController required a bean of type 'com.project.currencyconversionservice.CurrencyExchangeServiceProxy' that could not be found.
Main file
@SpringBootApplication
@EnableFeignClients("com.project.currencyconversionservice")
public class CurrencyConversionServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CurrencyConversionServiceApplication.class, args);
}
}
CurrencyConversionController.java
@GetMapping("/currency-converter-feign/from/{from}/to/{to}/quantity/{quantity}")
public CurrencyConversionBean converCurrencyFeign(
@PathVariable String from, @PathVariable String to, @PathVariable BigDecimal quantity)
{
CurrencyConversionBean response = proxy.retrieveExchangeValue(from, to);
return new CurrencyConversionBean(response.getId(),from,to,response.getConversionMultiple(),
quantity,quantity.multiply(response.getConversionMultiple()),response.getPort());
//return new CurrencyConversionBean(1L,from,to,BigDecimal.ONE,quantity,quantity,0);
}
CurrencyExchangeServiceProxy.java
@FeignClient(name="currency-exchange-service")
@RibbonClient(name="currency-exchange-service")
public interface CurrencyExchangeServiceProxy {
@GetMapping("currency-exchange/from/{from}/to/{to}")
public CurrencyConversionBean retrieveExchangeValue(@PathVariable String from, @PathVariable String to);
}
application.properties
spring.application.name=currency-conversion-service
server.port=8100
currency-exchange-service.ribbon.listOfServers=http://localhost:8000,http://localhost:8001`your text`
CurrencyExchangeController.java
@Autowired
private Environment environment;
@Autowired
private ExchangeValueRepository exchangeValueRepository;
@GetMapping("currency-exchange/from/{from}/to/{to}")
public ExchangeValue retrieveExchangeValue(@PathVariable String from, @PathVariable String to)
{
//ExchangeValue exchangeValue = new ExchangeValue(1000L, from, to, BigDecimal.valueOf(65));
ExchangeValue exchangeValue = exchangeValueRepository.findByCfromAndCto(from,to);
exchangeValue.setPort(Integer.parseInt(environment.getProperty("local.server.port")));
return exchangeValue;
}