1. build.gradle

    // feign client
    implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '3.1.1'
    
  2. 최상단 Application class

  1. 외부 url 관리를 yml로 설정 (optional)

    # Django Converter IP
    feign:
      secret:
        converterIP : <http://www.domain.com:9000>
        elasticsearchIP: <http://www.domain2.com:9200>
    
  2. Client interface

    import org.springframework.cloud.openfeign.FeignClient;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    
    import java.util.Map;
    
    @FeignClient(name = "elasticsearchClient", url = "${feign.secret.elasticsearchIP}")
    public interface ElasticsearchClient {
    
        /**
         * 통합검색 > 논문 검색
         */
        @RequestMapping(method = RequestMethod.POST, value = "/paper/_search")
        Map<String, Object> searchPapers(@RequestBody Map<String, Object> body);
    }
    
  3. client 사용하는 class 예시

    Map<String, Object> response = elasticsearchFeignClient.searchPapers(requestBody);