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

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

Spring Cloud feign

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

pom文件

導(dǎo)入包

<!-- 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)用其他微服務(wù)--> <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ā)表
主站蜘蛛池模板: 漳浦县| 长汀县| 大石桥市| 托克逊县| 平原县| 德钦县| 和政县| 宜阳县| 吉林省| 新巴尔虎右旗| 东辽县| 北安市| 开江县| 延川县| 张掖市| 贡觉县| 宿州市| 中卫市| 方城县| 长海县| 遂宁市| 永吉县| 开原市| 胶南市| 永嘉县| 泰安市| 孟村| 江安县| 西平县| 铁岭市| 阿瓦提县| 府谷县| 遵义市| 顺昌县| 横山县| 肃宁县| 广州市| 达州市| 东兰县| 曲水县| 竹山县|