Table of contents
Configure JVM startup parameters
import pom
This is the official way, springboot needs to introduce
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> <version>2.1.2.RELEASE</version> </dependency>
In addition to this, it is also necessary to introduce the core package and the sentinel client-dashboard communication package. Without importing, it cannot be registered on the dashboard.
<!--阿里的限流工具 sentinel-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-annotation-aspectj</artifactId>
<version>1.8.0</version>
</dependency>
<!-- sentinel客户端与dashboard通信依赖 -->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-transport-simple-http</artifactId>
<version>1.8.0</version>
</dependency>
At this time, if an error is reported, it means that two classes refer to each other, causing Spring to not know which one to initialize first when initializing the bean, thus forming a circular dependency injection.
Modification method. yaml file plus
spring: main: allow-circular-references: true
Configure JVM startup parameters
The startup parameters need to be added
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
It can also be configured in yaml, specifically Baidu
At this time, you can register successfully, see your service on the dashboard, and proceed to the next step
Error resolution
1、ClassNotFoundException com.alibaba.csp.sentinel.spi.ServiceLoaderUtil in version 1.8.1
This does not actually affect the use, because the report lacks dependencies. There are big guys on github who have already given a solution. Just replace the correct version. I use 1.8.0, and there is no problem.