zoukankan      html  css  js  c++  java
  • SC Alibaba20211030 Nacos 微服务框架结构 SerivceImplOrder <OpenFeign> SerivceImplMember

     

     

     

     

     

     

     

     

     

     

     

    实例SerivceImplOrder  

     

    注: SerivceImplOrder  2020 调用<OpenFeign>  SerivceImplMember2019

    i)、pom.xml

      <dependencies>
        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        <version>2.2.2.RELEASE</version>
      </dependency>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
        <version>2.0.0.RELEASE</version>
      </dependency>
      <dependency>
        <groupId>com.netflix.archaius</groupId>
        <artifactId>archaius-core</artifactId>
        <version>0.7.6</version>
        <exclusions>
          <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
      </exclusions>
      </dependency>
     </dependencies>


    ii)、MemberServiceFeign

      @FeignClient("ServiceImplMember")
      public interface MemberServiceFeign {

        @GetMapping("/getUser")
        public String getUser(@RequestParam("useId") Integer useId);


    iii)、OrderService
      @RestController
      public class OrderService {

        @Autowired
        private MemberServiceFeign memberServiceFeign;

        @RequestMapping("/orderFeignToMember")
          public String orderFeignToMember(){
            String result=memberServiceFeign.getUser(1);
            return "【ServiceImplOrder 2020】我是订单服务调用会员服务【ServiceImplMember 2019】的接口"+result;
        }
      }


    iiii)、Application

      @SpringBootApplication
      @EnableFeignClients
      public class ServiceImplOrderApplication {

        public static void main(String[] args) {
        SpringApplication.run(ServiceImplOrderApplication.class, args);
        }
      }


    iiiii)、application.properties


      # 应用名称
      spring.application.name=ServiceImplOrder
      # 应用服务 WEB 访问端口
      server.port=2020
      # Nacos帮助文档: https://nacos.io/zh-cn/docs/concepts.html
      # Nacos认证信息
      spring.cloud.nacos.discovery.username=nacos
      spring.cloud.nacos.discovery.password=nacos
      # Nacos 服务发现与注册配置,其中子属性 server-addr 指定 Nacos 服务器主机和端口
      spring.cloud.nacos.discovery.server-addr=http://127.0.0.1:8848
      # 注册到 nacos 的指定 namespace,默认为 public
      spring.cloud.nacos.discovery.namespace=public

    iiiiii)、

  • 相关阅读:
    Spring HttpIvoker实现Java的远程调用
    基于struts2框架文件的上传与下载
    12月9号linux学习
    2019.7.7 练习题
    题解 儿童节继续欢乐赛
    Winfroms看看吧客官~
    group by应用
    基于Windows Azure 搭建基于SharePoint 2010 Intranet、Extranet、Internet (1): 安装SharePoint 2010
    基于Windows Azure 搭建基于SharePoint 2010 Intranet、Extranet、Internet (2): 创建并发布SharePoint Intranet站点
    Inside Microsoft SharePoint 2010 简译(1): SharePoint 2010开发者路线图
  • 原文地址:https://www.cnblogs.com/smallfa/p/15493826.html
Copyright © 2011-2022 走看看