Reputation: 1
Error : Field proxy in com.project.currencyconversionservice.CurrencyConversionController required a bean of type 'com.project.currencyconversionservice.CurrencyExchangeServiceProxy' that could not be found.
@SpringBootApplication
@EnableFeignClients("com.project.currencyconversionservice")
public class CurrencyConversionServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CurrencyConversionServiceApplication.class, args);
}
}
@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);
}
@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);
}
spring.application.name=currency-conversion-service
server.port=8100
currency-exchange-service.ribbon.listOfServers=http://localhost:8000,http://localhost:8001`your text`
@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;
}
Upvotes: 0
Views: 124
Reputation: 1
I found the solution for above issue, Spring boot version 2.7.9 wont support Ribbon Loadbalancer, so i downgraded my spring boot version from 2.7.9 to 2.3.1.RELEASE.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.9</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.6</spring-cloud.version>
</properties>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR5</spring-cloud.version>
</properties>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
Upvotes: 0