国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

Spring Cloud feign

2019-11-10 21:05:05
字體:
供稿:網(wǎng)友

pom文件

導入包

<!-- sPRing-cloud-feign --> <dependency> <groupId>com.netflix.feign</groupId> <artifactId>feign-httpclient</artifactId> <version>${feign-httpclient.version}</version> </dependency> <dependency> <groupId>com.netflix.feign</groupId> <artifactId>feign-core</artifactId> <version>${feign-httpclient.version}</version> </dependency> <dependency> <groupId>com.netflix.feign</groupId> <artifactId>feign-gson</artifactId> <version>${feign-httpclient.version}</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> <version>1.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter</artifactId> <version>1.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-client</artifactId> <version>1.2.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> <version>1.2.4.RELEASE</version> </dependency> <!--調(diào)用其他微服務--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-ribbon</artifactId> <version>1.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> <version>1.2.5.RELEASE</version> </dependency> <!-- spring-cloud-feign end -->

寫一個接口 FeignInterface

import org.springframework.cloud.netflix.feign.FeignClient;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import java.util.List;/** * Created by Administrator on 2017/2/5. */@FeignClient(name="ribbonserver", url="http://localhost:8080")public interface FeignInterface { @RequestMapping(value = "/baseBackStage/index", method = RequestMethod.GET) ResponseEntity<String> index();}

新建FeignController

import feign.Feign;import feign.Logger;import feign.codec.Decoder;import feign.gson.GsonDecoder;import io.swagger.annotations.Api;import io.swagger.annotations.ApiImplicitParams;import io.swagger.annotations.ApiOperation;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RestController;import java.util.Base64;import java.util.List;@Api(value = "Feign測試使用",description = "Feign測試使用")@RequestMapping("/feigntest")@RestControllerpublic class FeignController { @Autowired FeignInterface feign; @ApiOperation(value = "Feign主測試使用") @ApiImplicitParams({}) @RequestMapping(value = "/index" ,method = RequestMethod.GET) public ResponseEntity<String > helloWord() { System.out.println("test Return================1"); Decoder decoder = new GsonDecoder(); ResponseEntity<String> responseEntity = feign.index(); String contributors = responseEntity.getBody(); System.out.println("test Return=="+contributors); return ResponseEntity.ok("hello word"); }}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 武鸣县| 固始县| 许昌县| 郴州市| 九寨沟县| 龙江县| 敦煌市| 调兵山市| 康平县| 玛纳斯县| 肥西县| 兴宁市| 香港 | 枣阳市| 京山县| 康定县| 兴海县| 吉木乃县| 大姚县| 玛纳斯县| 泽普县| 南丹县| 江华| 德钦县| 泸水县| 宝应县| 大厂| 永顺县| 吴桥县| 大竹县| 常州市| 江口县| 辉南县| 宜宾县| 郯城县| 石渠县| 南宁市| 阿城市| 四子王旗| 成都市| 湘潭市|