当前位置: 首页 > news >正文

做网站的标签及属性中文域名注册费用标准

做网站的标签及属性,中文域名注册费用标准,wordpress手机端底部按钮,linux网站备份Feign简介#xff1a; Feign是一种声明式、模板化的HTTP客户端。在Spring Cloud中使用Feign, 我们可以做到使用HTTP请求远程服务时能与调用本地方法一样的编码体验。 Feign是在RestTemplate基础上封装的#xff0c;使用注解的方式来声明一组与服务提供者Rest接口所对应的本地…Feign简介 Feign是一种声明式、模板化的HTTP客户端。在Spring Cloud中使用Feign, 我们可以做到使用HTTP请求远程服务时能与调用本地方法一样的编码体验。 Feign是在RestTemplate基础上封装的使用注解的方式来声明一组与服务提供者Rest接口所对应的本地Java API接口方法。 Feign将远程Rest接口抽象成一个声明式的FeignClientJava API客户端并且负责完成FeignClient客户端和服务提供方的Rest接口绑定。 整体目录 feignconsumer消费方代码 为了让Feign知道在调用方法时应该向哪个地址发请求以及请求需要带哪些参数我们需要定义一个接口Spring Cloud应用在启动时Feign会扫描标有FeignClient注解的接口生成代理并注册到Spring容器中。生成代理时Feign会为每个接口方法创建一个RequetTemplate对象该对象封装了HTTP请求需要的全部信息请求参数名、请求方法等信息都是在这个过程中确定的Feign的模板化就体现在这里. UserClient package com.tt.consumer.client;import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable;/*** 有关消费者client,配置需要调用服务者的名字*/ FeignClient(name tt-sc-feign-provide) //对应的要调用提供者服务名spring.application.name public interface UserClient {/*** 通过用户id获取用户* param userId* return*/GetMapping(/user/getUser/{userId})//对应要调用提供者的controllerString getUser(PathVariable(userId) String userId); }FeignConsumerController package com.tt.consumer.controller;import com.tt.consumer.client.UserClient; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import javax.annotation.Resource;/*** 平台controller业务逻辑引入client出发消费者调用提供者*/ Api(tags 用户模块) RestController RequestMapping(user) public class FeignConsumerController {Value(${server.port})private String port;Resourceprivate UserClient userClient;/*** 通过用户ID获取用户* param userId* return*/ApiOperation(value 根据用户ID查询用户)GetMapping(/getUserInfo/{userId})public String getUserInfo(PathVariable(userId) String userId){String user userClient.getUser(userId);return String.format(【%s-Demo消费者】调用Feign接口返回值 %s, port, user);}} NacosFeignConsumerApplication package com.tt.consumer;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; /*** 代表自己是一个服务消费者*/ SpringBootApplication //声明此服务可作为消费者使用配置feign客户端目录 EnableFeignClients(basePackages com.tt.consumer.client) public class NacosFeignConsumerApplication {public static void main(String[] args) {SpringApplication.run(NacosFeignConsumerApplication.class, args);} } application-dev.yml未配置信息bootstrap.yml如下 server:port: 8083 spring:profiles:active: devapplication:name: tt-sc-feign-consumercloud:nacos:username: nacospassword: nacosconfig:server-addr: 127.0.0.1:8848file-extension: ymldiscovery:server-addr: 127.0.0.1:8848pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringcloud/artifactIdgroupIdcom.example/groupIdversion0.0.1-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdfeignconsumer/artifactId dependencies!-- 引入SpringCloud的Nacos server依赖 --!--服务发现pom--dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactIdversion2.2.3.RELEASE/version/dependency!-- feign --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactIdversion2.2.1.RELEASE/version/dependencydependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-config/artifactIdversion2.2.3.RELEASE/version/dependencydependencygroupIdio.swagger/groupIdartifactIdswagger-annotations/artifactIdversion1.5.20/versionscopecompile/scope/dependency/dependencies/projectfeignprovide提供方代码 NacosFeignProvideApplication package com.tt.feignprovide;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; /*** 服务提供方-供feignclient使用**/ EnableDiscoveryClient SpringBootApplication public class NacosFeignProvideApplication {public static void main(String[] args) {SpringApplication.run(NacosFeignProvideApplication.class, args);}} UserProvideController package com.tt.feignprovide.controller;import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;Api(tags 用户模块) RestController RequestMapping(user) public class UserProvideController {Value(${server.port})private String port;/*** 通过用户ID获取用户* param userId* return*/ApiOperation(value 根据用户ID查询用户)GetMapping(/getUser/{userId})public String getUser(PathVariable(userId) String userId){return String.format(【%s-服务提供者】%s, port, userId);}} application-dev.yml未配置信息bootstrap.yml如下 server:port: 8082 spring:profiles:active: devapplication:name: tt-sc-feign-providecloud:nacos:username: nacospassword: nacosconfig:server-addr: 192.168.10.107:8848file-extension: ymldiscovery:server-addr: 192.168.10.107:8848 pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringcloud/artifactIdgroupIdcom.example/groupIdversion0.0.1-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersion !-- packagingpom/packaging--artifactIdfeignprovide/artifactIddependencies!-- nacos 客户端 作为 注册与发现--dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactIdversion2.2.3.RELEASE/version/dependency!-- nacos 配置中心 --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-config/artifactIdversion2.2.3.RELEASE/version/dependency!-- feign 调用服务接口 --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactIdversion2.2.1.RELEASE/version/dependencydependencygroupIdio.swagger/groupIdartifactIdswagger-annotations/artifactIdversion1.5.20/versionscopecompile/scope/dependency/dependencies/project父类pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionpackagingpom/packagingmodulesmodulecommon/modulemodulemanage/modulemodulett-sc-generator/modulemodulefeignprovide/modulemodulefeignconsumer/module/modulesparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.3.3.RELEASE/version !-- version2.1.8.RELEASE/version--relativePath/ !-- lookup parent from repository --/parentgroupIdcom.example/groupIdartifactIdspringcloud/artifactIdversion0.0.1-SNAPSHOT/versionnamespringcloud/namedescriptionDemo project for Spring Boot/descriptionpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncodingjava.version1.8/java.versionspring.boot.version2.3.3.RELEASE/spring.boot.versionspring.cloud.versionHoxton.SR8/spring.cloud.versionspring.cloud.sleuth.version2.2.3.RELEASE/spring.cloud.sleuth.versionswagger2.version2.9.2/swagger2.versionswagger-models.version1.6.0/swagger-models.versionswagger-annotations.version1.6.0/swagger-annotations.versiondruid.starter.vsersion1.1.21/druid.starter.vsersioncommons.lang.version2.4/commons.lang.versioncommons.lang3.version3.7/commons.lang3.versioncommons.collections.version3.2.1/commons.collections.versioncommons.io.version2.6/commons.io.versionspring.cloud.alibaba.version2.1.2.RELEASE/spring.cloud.alibaba.version/propertiesdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion${spring.cloud.version}/versiontypepom/typescopeimport/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-alibaba-dependencies/artifactIdversion${spring.cloud.alibaba.version}/versiontypepom/typescopeimport/scope/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project 测试结果
http://www.hkea.cn/news/14294738/

相关文章:

  • 做外贸没有网站需要做毕业设计资料网站
  • vs 网站开发教程自己做网站打开是乱码
  • 佛山建站佛山网页设计营销型网站建设_做网站
  • 建设网站需要学什么WordPress瀑布流图片站
  • 郑州百度网站建设武威 网站建设
  • 快三网站开发长沙招聘信息2022
  • 视频播放网站开发的报告网站域名需icp备案
  • 如何不花钱开发网站小白学做搭建网站
  • 阿里云静态网站托管南宁市住房城乡建设厅网站
  • 电子商务网站建设实训目的淘宝网手机版
  • 广州海珠网站开发方案电商网站 建社区
  • 成都网站建设成都网络公司门户网站建设需要多少钱
  • 张家界做旅游网站seo网站建设技巧
  • 装修公司网站制作公司做企业网站的必要性
  • 三原网站建设个人如何申请网址
  • 做网站的需要注册商标吗吉林seo推广系统
  • 彩票网站wordpress模板西安市建设局网站
  • 厦门汽车充电站建设报备网站桂林象鼻山作文300字
  • 保定网站建设咨询哪个网站的域名到期直接注册
  • 国外特效网站免费特效模板下载
  • 网站网页区别是什么意思layui做网站
  • 网站制作域名是免费的吗网站建设中期怎么入账
  • 网站右下角弹窗代码背景音乐 wordpress
  • 电子商务官方网站做外贸什么网站
  • 网站建设与维护案例中小企业怎么优化网站
  • dedecms 门户网站垡头做网站的公司
  • 临沂网站优化网站建设电话销售的话术
  • wordpress网站更新开网店哪些平台不收费
  • 做知识问答的网站dede模板打网站显示栏logo
  • 如何做拉勾勾网站宁波网站制作公司费用价格