• Spring Cloud Alibaba 整合 Sentinel


    https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel

    如果要在您的项目中引入 Sentinel,使用 group ID 为 com.alibaba.cloud 和 artifact ID 为 spring-cloud-starter-alibaba-sentinel 的 starter。

    <!-- sentinel 启动器 -->
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
            </dependency>

    pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>springcloudalibaba</artifactId>
            <groupId>com.wsm.springcloud</groupId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>order-sentinel</artifactId>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
    <!--            <version>2.5.5</version>-->
            </dependency>
    
            <!-- sentinel 启动器 -->
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
            </dependency>
        </dependencies>
    
    
    
    </project>

    application.yml

    server:
      port: 8052
      #应用名称  (sentinel 会将该名称当作服务名称)
    spring:
      application:
        name: order-sentinel
      cloud:
        sentinel:
          transport:
            dashboard: 127.0.0.1:8858
    package com.wsm.order.controller;
    
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    @RequestMapping("/order")
    public class OrderController {
        
        @RequestMapping("/add")
        public String add(){
            System.out.println("aaaaaaaaaaaaa");
            return "hello world";
        }
    }
    package com.wsm.order;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.web.client.RestTemplateBuilder;
    import org.springframework.context.annotation.Bean;
    import org.springframework.web.client.RestTemplate;
    
    @SpringBootApplication
    public class OrderApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(OrderApplication.class,args);
        }
    
    }

     

  • 相关阅读:
    Jhipster 一个Spring Boot + Angular/React 全栈框架
    从企业架构到智慧油田的理论与实践
    DevExpress VCL 的 cxDBTreeList 的使用方法
    Delphi 三层框架 DataSnap 的服务器端设置
    雷达方程
    雷达方向信号产生
    目标
    流水线&并行处理
    CORDIC原理与FPGA实现(2)
    CORDIC原理与FPGA实现(1)
  • 原文地址:https://www.cnblogs.com/mingforyou/p/15624926.html
Copyright © 2020-2023  润新知