码迷,mamicode.com
首页 > 编程语言 > 详细

springcloud框架一套流程理解

时间:2018-03-12 16:56:39      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:word   ade   默认   ble   excludes   nal   配置   cli   def   

 eureka server服务中心  是把所有的eureka client各个服务  都注册到服务中心上 

例如服务 A B C中配置如下:

application.yml文件配置:

技术分享图片
 1 server: 
 2   port: 10003
 3 spring: 
 4   mvc: 
 5     favicon: 
 6       enabled: false
 7 eureka: 
 8   client: 
 9     service: 
10     serviceUrl:
11       defaultZone: http://127.0.0.1:9998/eureka/  
12 //这里就是服务中心的配置文件
13 pagehelper:
14   helperDialect : mysql
15   reasonable : true
16   supportMethodsArguments : true
17   params : count=countSql   
18 tg: 
19  sercurity: 
20    filter: 
21       includes: /energy/*
22       excludes: /energy/metering/*,/energy/enterprise/*,/energy/process/*,/energy/processunit/*,/energy/collectItemConfig/*,
23        /energy/sys/*,/energy/park/*,/energy/parkEnterprise/*,/energy/enengyRate/*,/energy/enengySaving/*,/energy/enengyStandard/*,/energy/analysis/*
24  db:
25    sharding: 
26      path: config/sharding.yml
27    default: em2_sysbase
28    customname: em2_sysbase
29    em2_sysbase: 
30       driverClassName: com.mysql.jdbc.Driver
31       url: jdbc:mysql://192.168.1.64:3306/em2_sysbase?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
32       username: root
33       password: 123456
34       filters: stat  
35       maxActive: 30
36       initialSize: 5
37       minIdle: 10
38       maxWait: 60000
39       validationQuery: SELECT 1 
40       testWhileIdle :  true
41       poolPreparedStatements :  true
42       maxOpenPreparedStatements :  100
43  
View Code

bootstrap.yml文件配置:

技术分享图片
1 spring:
2   application: 
3     name: em2-energy-service
4   redis: 
5     host: 127.0.0.1
6     port:3369
View Code

服务中心yml配置文件

技术分享图片
 1 server:
 2   port: 9998    //这个端口以后就是登陆的时候输入进去的
 3 
 4 eureka:
 5   instance:
 6     hostname: 127.0.0.1
 7   client:
 8     registerWithEureka: false   //是否注册到服务中心默认true
 9     fetchRegistry: false
10     serviceUrl:
11       defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/    
View Code

zuul是集路由 负载均衡 熔断器等一体的服务

它的yml配置如下:

技术分享图片
 1 server: 
 2   port: 9999    //登陆用的
 3 zuul: 
 4   routes: 
 5     auth: 
 6       customSensitiveHeadsers: true
 7       sensitiveHeaders: 
 8       stripPrefix: false
 9       path: /auth/**
10       serviceId: em2-auth-service    
11 //path就是url的请求到这里会被拦截通过serviceId进入到当前的服务,serviceId这个就是各个服务的application name,stripPrefix: false这个是对/api做的过滤
12     static: 
13       customSensitiveHeadsers: true
14       sensitiveHeaders: 
15       path: /static/**
16       stripPrefix: true
17       serviceId: em2-ui
18     oss: 
19       path: /oss/**
20       url: http://192.168.1.64:10010/
21       stripPrefix: false
22   max:
23     host:
24       connections: 500
25   host:
26     socket-timeout-millis: 120000
27     connect-timeout-millis: 120000
28 eureka: 
29   client: 
30     service: 
31     serviceUrl:
32       defaultZone: http://127.0.0.1:9998/eureka/
33 
34 ##timeout config
35 hystrix:
36   command:
37     default:
38       execution:
39         timeout:
40           enabled: false
41         isolation:
42           thread:
43             timeoutInMilliseconds: 120000
44 ribbon:
45   ReadTimeout: 120000
46   ConnectTimeout: 120000
47   MaxAutoRetries: 0
48   MaxAutoRetriesNextServer: 1
49   eureka:
50     enabled: true
View Code

 

springcloud框架一套流程理解

标签:word   ade   默认   ble   excludes   nal   配置   cli   def   

原文地址:https://www.cnblogs.com/hjb90/p/8549395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!