Skip to content

Commit 8caedb6

Browse files
committed
Spring Cloud Alibaba基础教程:Sentinel使用Nacos存储规则
1 parent 0763b2a commit 8caedb6

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.didispace</groupId>
7+
<artifactId>alibaba-sentinel-datasource-nacos</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.0.5.RELEASE</version>
15+
<relativePath/> <!-- lookup parent from repository -->
16+
</parent>
17+
18+
<properties>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
21+
<java.version>1.8</java.version>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-web</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework.cloud</groupId>
31+
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.alibaba.csp</groupId>
35+
<artifactId>sentinel-datasource-nacos</artifactId>
36+
<version>1.4.0</version>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.projectlombok</groupId>
41+
<artifactId>lombok</artifactId>
42+
<version>1.18.2</version>
43+
<optional>true</optional>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-starter-test</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
</dependencies>
51+
52+
<dependencyManagement>
53+
<dependencies>
54+
<dependency>
55+
<groupId>org.springframework.cloud</groupId>
56+
<artifactId>spring-cloud-dependencies</artifactId>
57+
<version>Finchley.SR1</version>
58+
<type>pom</type>
59+
<scope>import</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.springframework.cloud</groupId>
63+
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
64+
<version>0.2.1.RELEASE</version>
65+
<type>pom</type>
66+
<scope>import</scope>
67+
</dependency>
68+
</dependencies>
69+
</dependencyManagement>
70+
71+
<build>
72+
<plugins>
73+
<plugin>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot-maven-plugin</artifactId>
76+
</plugin>
77+
</plugins>
78+
</build>
79+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.didispace.alibaba.sentinel;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
10+
@SpringBootApplication
11+
public class TestApplication {
12+
13+
public static void main(String[] args) {
14+
SpringApplication.run(TestApplication.class, args);
15+
}
16+
17+
@Slf4j
18+
@RestController
19+
static class TestController {
20+
21+
@GetMapping("/hello")
22+
public String hello() {
23+
return "didispace.com";
24+
}
25+
26+
}
27+
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring.application.name=alibaba-sentinel-datasource-nacos
2+
server.port=8003
3+
4+
# sentinel dashboard
5+
spring.cloud.sentinel.transport.dashboard=localhost:8080
6+
7+
# sentinel datasource nacos :
8+
spring.cloud.sentinel.datasource.ds.nacos.server-addr=localhost:8848
9+
spring.cloud.sentinel.datasource.ds.nacos.dataId=${spring.application.name}-sentinel
10+
spring.cloud.sentinel.datasource.ds.nacos.groupId=DEFAULT_GROUP

4-Finchley/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<module>alibaba-nacos-discovery-client-feign</module> <!-- 使用Nacos实现服务注册与发现:服务消费方(Feign实现)-->
2020

2121
<module>alibaba-sentinel-rate-limiting</module> <!-- 使用Sentinel实现接口限流 -->
22+
<module>alibaba-sentinel-datasource-nacos</module> <!-- 使用Nacos存储规则 -->
2223
<module>alibaba-sentinel-datasource-apollo</module> <!-- 使用Apollo存储规则 -->
2324

2425
<!--spring cloud stream专题-->

0 commit comments

Comments
 (0)