2017-10-17 3 views
0

私は春のブートが初めてです。 CRUD操作を使って定義されたサービスにアクセスできるアプリを作成しました。すべてのチュートリアルで同じことが説明されています。今、私は休憩をしたい遠隔アプリケーションを持っています。私は自分のアプリがリモートエンドポイントを認識させる方法として知りたいです。私のyamlまたはプロパティファイルでそのアプリケーションを定義し、そのサービスにアクセスする方法。いくつかの相対的なチュートリアルを指摘すると非常に役に立ちます。2つのスタンドアロンのスプリングブートアプリケーション間で休憩をとる

+0

(https://spring.io/guides/gs/consuming-resの下に使用することができますt /)を公式ウェブサイトで公開しています。 – LHCHIN

答えて

0

それはあなたがここに探しているものにいくつかの情報を見つけることができます。..

私はあなたが任意の有用な情報を見つけることができなかったことを信じることのために懸命だが、とにかくここに行く:

http://www.baeldung.com/rest-template

0

あなたは、コードスニペット

//Imports 
import org.springframework.core.io.Resource; 
import org.springframework.http.HttpEntity; 
import org.springframework.http.HttpMethod; 
import org.springframework.http.MediaType; 
import org.springframework.http.ResponseEntity; 
import org.springframework.util.LinkedMultiValueMap; 
import org.springframework.util.MultiValueMap; 
import org.springframework.util.StringUtils; 
import org.springframework.web.client.RestTemplate; 

//Implementation 
RestTemplate restTemplate = ContextProvider.getBean(RestTemplate.class); 
ResponseEntity<ReturnType> data=null; 

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); 

if(headers.isEmpty()){ 
    headers.add("Accept", MediaType.APPLICATION_JSON_VALUE); 
    headers.add("Content-Type", MediaType.APPLICATION_JSON_VALUE); 
} 

Map<String, Object> params = new HashMap<String, Object>() {{ 
    put("<paramname>",<paramvalue>);        
}}; 

ResponseEntity<ReturnType> data = restTemplate.exchange(<url>, HttpMethod.POST, new HttpEntity<Object>(params, headers), ReturnType.class); 
あなたは[RESTfulなWebサービスを利用する]のこのチュートリアルを参照することができます