sentinel–基础–03–整合springboot
代码位置
https://gitee.com/DanShenGuiZu/learnDemo/tree/master/sentinel_learn/demo2
1、引入依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>2023.0.1.0</version>
</dependency>
2、添加配置
spring:
cloud:
sentinel:
transport:
dashboard: 127.0.0.1:8080 #控制台地址
3、测试
3.1、测试代码
@RestController
public class HelloController {
protected Logger logger = LoggerFactory.getLogger(getClass());
@RequestMapping("/getId/{id}")
public Integer getId(@PathVariable("id") Integer id) {
return id;
}
}
先要请求这个接口,才能在sentinel控制台上看到数据
http://127.0.0.1:5569/getId/5