Skip to content

Commit 1bd4ccd

Browse files
committed
完善feign和sentinel的集成
1 parent 3123e1f commit 1bd4ccd

File tree

11 files changed

+77
-50
lines changed

11 files changed

+77
-50
lines changed

auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/provider/ResourceProviderFallback.java

+2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import com.springboot.cloud.sysadmin.organization.entity.po.Resource;
44
import com.springboot.cloud.common.core.entity.vo.Result;
5+
import org.springframework.stereotype.Component;
56

67
import java.util.HashSet;
78
import java.util.Set;
89

10+
@Component
911
public class ResourceProviderFallback implements ResourceProvider {
1012
@Override
1113
public Result<Set<Resource>> resources() {

auth/authentication-server/src/main/resources/application.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@ spring:
1313
url: jdbc:${DATASOURCE_DBTYPE:mysql}://${DATASOURCE_HOST:localhost}:${DATASOURCE_PORT:3306}/sc_auth?characterEncoding=UTF-8&useUnicode=true&useSSL=false
1414
username: ${DATASOURCE_USERNAME:root}
1515
password: ${DATASOURCE_PASSWORD:root123}
16-
1716
zipkin:
1817
enabled: true
1918
sender:
2019
type: rabbit
2120
sleuth:
2221
sampler:
2322
probability: 1.0
24-
2523
mvc:
2624
throw-exception-if-no-handler-found: true
27-
2825
#jwt的密钥
2926
security:
3027
oauth2:
3128
jwt:
3229
signingKey: 123456
3330

31+
feign:
32+
sentinel:
33+
enabled: true
34+
okhttp:
35+
enabled: true
36+
3437
logging:
3538
level:
3639
org.springframework.web: debug
@@ -50,3 +53,4 @@ management:
5053
mybatis:
5154
configuration:
5255
map-underscore-to-camel-case: true
56+

auth/authorization-server/src/main/java/com/springboot/auth/authorization/provider/OrganizationProviderFallback.java

+2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import com.springboot.auth.authorization.entity.Role;
44
import com.springboot.auth.authorization.entity.User;
55
import com.springboot.cloud.common.core.entity.vo.Result;
6+
import org.springframework.stereotype.Component;
67

78
import java.util.HashSet;
89
import java.util.Set;
910

11+
@Component
1012
public class OrganizationProviderFallback implements OrganizationProvider {
1113

1214
@Override

auth/authorization-server/src/main/resources/application.yml

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ logging:
4141
file:
4242
max-size: 1GB
4343

44+
feign:
45+
sentinel:
46+
enabled: true
47+
okhttp:
48+
enabled: true
49+
4450
management:
4551
endpoints:
4652
web:

demos/consumer-feign/src/main/resources/application.yml

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
server:
2-
port: 8041
3-
41
spring:
5-
application:
6-
name: feign-consumer
7-
cloud:
8-
nacos:
9-
discovery:
10-
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
11-
sentinel:
12-
transport:
13-
dashboard: ${SENTINEL_DASHBOARD_HOST:localhost}:${SENTINEL_DASHBOARD_PORT:8021}
14-
152
rabbitmq:
163
host: ${RABBIT_MQ_HOST:localhost}
174
port: ${RABBIT_MQ_PORT:5672}
185
username: ${RABBIT_MQ_USERNAME:guest}
196
password: ${RABBIT_MQ_PASSWORD:guest}
20-
217
zipkin:
228
sender:
239
type: rabbit
@@ -29,7 +15,6 @@ spring:
2915
enabled: true
3016
processor:
3117
enabled: true
32-
3318
mvc:
3419
throw-exception-if-no-handler-found: true
3520
servlet:
@@ -46,6 +31,12 @@ logging:
4631
file:
4732
max-size: 1GB
4833

34+
feign:
35+
sentinel:
36+
enabled: true
37+
okhttp:
38+
enabled: true
39+
4940
management:
5041
endpoints:
5142
web:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server:
2+
port: 8041
3+
spring:
4+
application:
5+
name: feign-consumer
6+
cloud:
7+
nacos:
8+
discovery:
9+
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
10+
config:
11+
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
12+
file-extension: yml
13+
sentinel:
14+
transport:
15+
dashboard: ${SENTINEL_DASHBOARD_HOST:localhost}:${SENTINEL_DASHBOARD_PORT:8021}
16+
bus:
17+
trace:
18+
enabled: true

demos/consumer-ribbon/src/main/resources/application.yml

-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
1-
server:
2-
port: 8020
3-
41
spring:
5-
application:
6-
name: ribbon-consumer
7-
cloud:
8-
nacos:
9-
discovery:
10-
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
11-
sentinel:
12-
transport:
13-
dashboard: ${SENTINEL_DASHBOARD_HOST:localhost}:${SENTINEL_DASHBOARD_PORT:8021}
14-
152
rabbitmq:
163
host: ${RABBIT_MQ_HOST:localhost}
174
port: ${RABBIT_MQ_PORT:5672}
185
username: ${RABBIT_MQ_USERNAME:guest}
196
password: ${RABBIT_MQ_PASSWORD:guest}
20-
217
zipkin:
228
enabled: true
239
sender:
2410
type: rabbit
2511
sleuth:
2612
sampler:
2713
probability: 1.0
28-
2914
mvc:
3015
throw-exception-if-no-handler-found: true
3116
servlet:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server:
2+
port: 8020
3+
spring:
4+
application:
5+
name: ribbon-consumer
6+
cloud:
7+
nacos:
8+
discovery:
9+
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
10+
config:
11+
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
12+
file-extension: yml
13+
sentinel:
14+
transport:
15+
dashboard: ${SENTINEL_DASHBOARD_HOST:localhost}:${SENTINEL_DASHBOARD_PORT:8021}
16+
bus:
17+
trace:
18+
enabled: true

demos/producer-jpa/src/main/resources/application.yml

-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
server:
2-
port: 9002
3-
41
spring:
5-
application:
6-
name: producer-jpa
7-
cloud:
8-
nacos:
9-
discovery:
10-
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
11-
sentinel:
12-
transport:
13-
dashboard: ${SENTINEL_DASHBOARD_HOST:localhost}:${SENTINEL_DASHBOARD_PORT:8021}
14-
152
rabbitmq:
163
host: ${RABBIT_MQ_HOST:localhost}
174
port: ${RABBIT_MQ_PORT:5672}
@@ -26,15 +13,13 @@ spring:
2613
url: jdbc:${DATASOURCE_DBTYPE:mysql}://${DATASOURCE_HOST:localhost}:${DATASOURCE_PORT:3306}/sc_product?characterEncoding=UTF-8&useUnicode=true&useSSL=false
2714
username: ${DATASOURCE_USERNAME:root}
2815
password: ${DATASOURCE_PASSWORD:root123}
29-
3016
zipkin:
3117
enabled: true
3218
sender:
3319
type: rabbit
3420
sleuth:
3521
sampler:
3622
probability: 1.0
37-
3823
mvc:
3924
throw-exception-if-no-handler-found: true
4025
servlet:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server:
2+
port: 9002
3+
spring:
4+
application:
5+
name: producer-jpa
6+
cloud:
7+
nacos:
8+
discovery:
9+
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
10+
config:
11+
server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
12+
file-extension: yml
13+
sentinel:
14+
transport:
15+
dashboard: ${SENTINEL_DASHBOARD_HOST:localhost}:${SENTINEL_DASHBOARD_PORT:8021}
16+
bus:
17+
trace:
18+
enabled: true

demos/producer/src/main/resources/application.yml

-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ spring:
2020
url: jdbc:${DATASOURCE_DBTYPE:mysql}://${DATASOURCE_HOST:localhost}:${DATASOURCE_PORT:3306}/sc_product?characterEncoding=UTF-8&useUnicode=true&useSSL=false
2121
username: ${DATASOURCE_USERNAME:root}
2222
password: ${DATASOURCE_PASSWORD:root123}
23-
2423
zipkin:
2524
enabled: true
2625
sender:
2726
type: rabbit
2827
sleuth:
2928
sampler:
3029
probability: 1.0
31-
3230
mvc:
3331
throw-exception-if-no-handler-found: true
3432
servlet:

0 commit comments

Comments
 (0)