SpringBoot 2.3.12.RELEASE
SpringCloudAlibaba 2.2.8.RELEASE
org.springframework.boot spring-boot-starter-web com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery com.alibaba.cloud spring-cloud-starter-alibaba-sentinel com.alibaba.csp sentinel-datasource-nacos org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-test test
删除项目的.properties文件改为bootstrap.yml文件
spring:application:name: springcloud-sentinelcloud:nacos:config:server-addr: 127.0.0.1:8848namespace: configfile-extension: yamlgroup: DEFAULT_GROUPdiscovery:server-addr: 127.0.0.1:8848bootstrap:enabled: true
# profiles:
# active: dev
server:port: 8085spring:application.name: springcloud-sentinelcloud:sentinel:transport.dashboard: localhost:8080datasource:ds.nacos:username: nacospassword: nacosruleType: flowgroupId: DEFAULT_GROUPdataId: ${spring.application.name}server-addr : localhost:8848
@RequestMapping("/test")
@RestController
public class HelloController {@Autowiredprivate TestService service;@GetMapping("/hello/{name}")public String hello(@PathVariable String name){return service.sayHello(name);}
}
@Service
public class TestService {@SentinelResource(value = "sayHello")public String sayHello(String name) {return "Hello, " + name;}
}
下载jar包地址
https://github.com/alibaba/Sentinel/releases
jar -jar sentinel-dashboard-1.8.1.jar
访问http://localhost:8080
用户名/密码 sentinel/sentinel




运行成功