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

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Spring Cloud feign

2019-11-10 20:36:44
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(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 -->

寫一個(gè)接口 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測(cè)試使用",description = "Feign測(cè)試使用")@RequestMapping("/feigntest")@RestControllerpublic class FeignController { @Autowired FeignInterface feign; @ApiOperation(value = "Feign主測(cè)試使用") @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ā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 大兴区| 托里县| 济南市| 含山县| 突泉县| 永嘉县| 武强县| 忻州市| 齐河县| 翁源县| 林州市| 通山县| 乌拉特后旗| 江阴市| 沛县| 泸州市| 利辛县| 洪雅县| 淮滨县| 垫江县| 永宁县| 济阳县| 海阳市| 玉溪市| 黑河市| 长春市| 新密市| 遂宁市| 紫阳县| 贺州市| 盐边县| 柳河县| 玉溪市| 镇平县| 霍州市| 东乡县| 来宾市| 镇赉县| 文安县| 枣阳市| 华坪县|