• 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)、

  • 相关阅读:
    接口测试断言详解(Jmeter)
    接口测试参数化详解(Jmeter)
    记一次线上内存泄漏问题的排查过程
    BI入门经典(转载)
    图形初阶
    数据的输入
    来自 Google 的 R 语言编码风格指南
    提醒程序员注意的一些事项--R
    R语言-attach、detach、with
    R数据类型
  • 原文地址:https://www.cnblogs.com/smallfa/p/15493826.html
Copyright © 2020-2023  润新知