title: How can I put the port and host in the property file in Spring?
body: <p>I have this url </p>
  
  <pre><code>private static final String PRODUCTS_URL = "http://localhost:3007/catalog/products/";
  </code></pre>
  
  <p>And this methods:</p>
  
  <pre><code>public JSONObject getProductByIdFromMicroservice(String id) throws IOException, JSONException {
          return getProductsFromProductMicroservice(PRODUCTS_URL + id);
      }
  
      public JSONObject getProductsFromProductMicroservice(String url) throws IOException, JSONException {
          CloseableHttpClient productClient = HttpClients.createDefault();
          HttpGet getProducts = new HttpGet(url);
  
          CloseableHttpResponse microserviceResponse = productClient.execute(getProducts);
          HttpEntity entity = microserviceResponse.getEntity();
          BufferedReader br = new BufferedReader(new InputStreamReader((entity.getContent())));
          StringBuilder sb = new StringBuilder();
  
          String line;
          while ((line = br.readLine()) != null) {
              sb.append(line);
          }
  
          br.close();
  
          System.out.println(sb.toString());
          JSONObject obj = new JSONObject(sb.toString());
          System.out.println(obj);
  
          return obj;
      }
  </code></pre>
  
  <p>I want to put the port and host in a separate property file. I have already seen examples using properties and the yml file. But I do not understand how then my methods will work using this port when creating an instance of the class, which I will indicate in the properties file. Can you tell?</p>