1.1 直接到Sentinel官网里的releases下即可下载最新版本,Sentinel官方下载地址,直接下载jar包即可。不过慢,可能下载不下来
1.2 可以去gitee去下载jar包
1.3 下载完成后,进行打包,
1.4 执行命令
打开命令行窗口,进入到项目里面,执行:
mvn clean package -DskipTests
java -jar sentinel-dashboard.jar
浏览器输入localhost:8084
账号密码:sentinel
4.0.0
org.example
sentinel
1.0-SNAPSHOT
8
8
UTF-8
org.springframework.boot
spring-boot-starter-parent
2.2.7.RELEASE
org.springframework.boot
spring-boot-starter-web
2.2.4.RELEASE
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.2
com.alibaba.cloud
spring-cloud-starter-alibaba-sentinel
2.2.5.RELEASE
server:
port: 8001
spring:
application:
name: sentinel-service
cloud:
sentinel:
transport:
dashboard: localhost:8084
eager: true
management:
endpoint:
web:
exposure:
include: '*'
package com.xxx;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class SentinelServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SentinelServiceApplication.class,args);
}
}
package com.xxx.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "test")
public class TestController {
@GetMapping(value = "/a")
public String test1() {
return "Hello,Sentinel --> 1";
}
@GetMapping(value = "/b")
public String test2() {
return "Hello,Sentinel --> 2";
}
}
http://localhost:8001/test/a
http://localhost:8001/test/b
有的时候在Sentinel控制台的簇点链路只显示/error和/**,无法显示相应的资源
解决方式:将这个依赖版本升级为2.2.5 即可
com.alibaba.cloud
spring-cloud-starter-alibaba-sentinel
2.2.5.RELEASE
点击流控按钮,新增流控规则即可
连续点击三次,就会出现限流操作,至此 搭建完成。。。