国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 大余县| 惠安县| 永顺县| 炎陵县| 涞水县| 广德县| 奈曼旗| 清镇市| 突泉县| 通榆县| 萨迦县| 海宁市| 江西省| 宁夏| 丹江口市| 宁河县| 宁夏| 彩票| 高州市| 新泰市| 内乡县| 津南区| 浦江县| 和静县| 连云港市| 自治县| 肥西县| 徐闻县| 白玉县| 博乐市| SHOW| 黄龙县| 盱眙县| 闸北区| 铁岭县| 日喀则市| 开封市| 石林| 西丰县| 景德镇市| 句容市|