目录
🧂2.特点
🧈3.下载
1.Sentinel是什么
2.特点
3.下载
官网:https://github.com/alibaba/Sentinel/releases/tag/1.7.0
小张提示:如果GitHub打不开,记得更改hosts文件~
4.sentinel启动
-
1.直接使用java -jar启动sentinel的jar包
- 2.访问浏览器localhost:8080
- 3.登录
5.实例演示
1.创建工程
2.加pom
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--springCloud alibaba Naocs-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--持久化-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<!--Sentinel-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!--openFeign-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
3.改yml
server:
port: 8401
spring:
application:
name: cloudalibaba-sentinel-service
cloud:
nacos:
discovery:
#nacos服务注册中心
server-addr: 192.168.20.50:1111
sentinel:
transport:
#sentinel dashboard地址
dashboard: localhost:8080
#默认8719端口,假如被占用会自动从8719开始依次+1扫描,直至找到未被占用的端口
port: 8719
management:
endpoints:
web:
exposure:
include: '*'
4.主启动类
@SpringBootApplication
@EnableDiscoveryClient
public class MainApp8401 {
public static void main(String[] args) {
SpringApplication.run(MainApp8401.class);
}
}
5.业务类
@RestController
public class FlowLimitController {
@GetMapping("/testA")
public String getTestA(){
return "-----TestA------";
}
@GetMapping("/testB")
public String getTestB(){
return "-----TestB------";
}
}
6.测试
注意:执行一下controller再访问