Skip to content

Commit 0dd6498

Browse files
committed
Spring Cloud Alibaba基础教程:Sentinel使用Apollo存储规则
1 parent 19dcb51 commit 0dd6498

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed

4-Finchley/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
- [Spring Cloud Alibaba基础教程:使用Sentinel实现接口限流](http://blog.didispace.com/spring-cloud-alibaba-sentinel-1/)
5050
- [Spring Cloud Alibaba基础教程:Sentinel使用Nacos存储规则](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-1/)
51+
- [Spring Cloud Alibaba基础教程:Sentinel使用Apollo存储规则](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-2/)
5152

5253
##### Spring Cloud Stream专题补充
5354

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-apollo</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-apollo</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,29 @@
1+
package com.didispace.alibaba.sentinel;
2+
3+
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
4+
import lombok.extern.slf4j.Slf4j;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
@EnableApolloConfig
11+
@SpringBootApplication
12+
public class TestApplication {
13+
14+
public static void main(String[] args) {
15+
SpringApplication.run(TestApplication.class, args);
16+
}
17+
18+
@Slf4j
19+
@RestController
20+
static class TestController {
21+
22+
@GetMapping("/hello")
23+
public String hello() {
24+
return "didispace.com";
25+
}
26+
27+
}
28+
29+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
local.meta=http://localhost:8080
2+
dev.meta=http://localhost:8080
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
spring.application.name=sentinel-datasource-apollo
2+
server.port=8002
3+
4+
# apollo config
5+
app.id=${spring.application.name}
6+
7+
# sentinel dashboard
8+
spring.cloud.sentinel.transport.dashboard=localhost:8080
9+
10+
# sentinel datasource apollo
11+
spring.cloud.sentinel.datasource.ds.apollo.namespaceName=application
12+
spring.cloud.sentinel.datasource.ds.apollo.flowRulesKey=sentinel.flowRules

0 commit comments

Comments
 (0)