I\'m trying to use Feign client. Below is my feing client:
import com.eprogrammerz.examples.domain.Movie;
import org.springframework.cloud.netflix.feign.Feig
If your Spring Cloud set up does not support specifying the servers in application.properties/application.yml, you have to configure the services URL in a Configuration class.
Pls, note the warning message in my application.properties [Spring Boot v2.0.0RELEASE, spring-cloud-starter-feign & spring-cloud-starter-ribbon v 1.4.3.RELEASE]
So what I did was to write a Configuration class as follows:
@Configuration
class LocalRibbonClientConfiguration {
@Bean
public ServerList ribbonServerList() {
// return new ConfigurationBasedServerList();
StaticServerList staticServerList = new StaticServerList<>((new Server("localhost", 8001)),
new Server("localhost", 8000));
return staticServerList;
}
}
Then, configured the Spring Boot Application to use this configuration as follows:
@SpringBootApplication
@EnableFeignClients("my-package.currencyconversionservice")
@RibbonClient(name = "currency-conversion-service", configuration = LocalRibbonClientConfiguration.class)
public class CurrencyConversionServiceApplication {
// nothing new here...
}
No need to change the Feign Proxy class. Posting just for this post to be served as a complete solution to the problem:
@FeignClient(name="currency-exchange-service")
@RibbonClient(name="currency-exchange-service")
public interface CurrencyExchangeServiceProxy {
@GetMapping("/currency-exchange/from/{from}/to/{to}")
public CurrencyConversionBean retrieveExchangeValue(@PathVariable("from") String from, @PathVariable("to") String to);
}
That's all. The problem was fixed.