title: Spring Boot - fetching data from another microservice
body: <p>I am using Spring Boot for my API. I am rewriting my API, to adopt the microservices architecture.</p>
  <p>I have 2 classes:</p>
  <p><strong>1) Product</strong></p>
  <p><strong>2) Ingredient</strong></p>
  <p>My Code:</p>
  <p>Here is my <strong>Product</strong> class:</p>
  <pre><code>    public class Product{
         private String name;
         @ElementCollection
         private List&lt;Long&gt; productIngredients = new ArrayList&lt;&gt;(); //Ingredient
         private Double quantity = 0.0;
         private Double productCost = 0.0;
  }
  </code></pre>
  <p>Here is my <strong>Ingredient</strong> class:</p>
  <pre><code>public class Ingredient{    
       private String name;
       private String unit;
       private Double quantity = 0.0;
  }
  </code></pre>
  <p>In the <strong>Product</strong> microservice, I am doing an API call to the <strong>Ingredient</strong> microservice:</p>
  <pre><code>// Making a call to the Ingredients microservice from the product microservice
  
  WebClient myWebClient = WebClient.create(&quot;http://localhost:8090/api&quot;);
  
  @GetMapping(&quot;/ingredients/get&quot;)
  public Flux&lt;Product&gt; getIngredients(){
     
          return myWebClient
                  .get()
                  .uri(&quot;/ingredients/ingredient/list&quot;)
                  .retrieve()
                  .bodyToFlux(Product.class);
  }
  </code></pre>
  <p>However, the above getIngredients() method is not working.</p>
  <p><strong>My Question:</strong></p>
  <p>I want to fetch data from the Ingredient microservice, however, I get the following error:</p>
  <blockquote>
  <p>&quot;error&quot;: &quot;Internal Server Error&quot;,
  &quot;trace&quot;: &quot;org.springframework.web.reactive.function.client.WebClientRequestException: Connection refused: no further information: localhost/127.0.0.1:80; nested exception is io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:80\r\n\tat org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141)\r\n\tSuppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: \nError has been observed at the following site(s):\n\t|_ checkpoint ⇢ Request to GET http://localhost/api/components/component/list [DefaultWebClient]\nStack trace:\r\n\t\tat org.springframework.web.reactive.function.client.</p>
  </blockquote>