eureka提供服务注册服务,各个节点启动后,会在Eureka 中进行注册,包括主机与端口号、服务版本号、通讯协议等。
这样Eureka中的服务注册表中将会存储所有可用服务节点的信息,服务节点的信息可以在界面中直观的看到。
输入用户:customer,输入密码:123456打开浏览页面。
server: #当前Spring-boot启动时占用的端口号===即服务注册中心的端口号 port: 9760 spring: application: name: eureka1 security: user: name: customer password: 123456 eureka: instance: #服务注册中心主机名 hostname: localhost prefer-ip-address: true instance-id: ${eureka.instance.hostname}:${server.port} client: service-url: #服务中心访问url地址 === 主机名:端口号/eureka defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:${server.port}/eureka/ #禁止eureka服务向自己注册服务 register-with-eureka: false #服务中心不去获取(fetch)其他服务,本职工作就是维护服务实例,而不是消费服务 #fetch-registry: false server: #服务中心 启用自我保护机制,剔除已关停的客户端节点(服务) enable-self-preservation: false
http://IP地址:9760
配置中心即config配置仓库来进行微服务连接,使用配置中心,使用配置中心方便、统一、快捷配置方式,支持Git、本地、GitLab多种连接方式。
server: port: 9780 redis-host: 192.168.1.203 rabbitmq-host: 192.168.1.203 spring: application: name: config cloud: config: server: #本地配置文件位置 native: search-locations: D:/zysd/sc/repository search-paths: base,production,test,zhaoxiace,songjingmin,liqiang,fengkai,luozhangheng,tangyuting,nirec,temp #git: #uri: file:///D:\zysd\sc\repository #uri: http://git.ewsd.cn/emis/repository.git #username: repository@zuoyour.com #password: repository@zuoyour.com #uri: https://github.com/xvpindex/ewsdSC-config-repository.git #username: xxxx@qq.com #password: 123456 #basedir: E:\wwwroot\java\ewsdSC\config\basedir #search-paths: base,production,test,zhaoxiace,songjingmin,zhuyongjing,fengkai,luozhangheng,tangyuting,nirec,temp # git仓库地址下的相对地址,配置多个用,分割。 redis: database: 0 host: ${server.redis-host} port: 6379 password: 123456 session: store-type: redis rabbitmq: host: ${server.rabbitmq-host} port: 5672 username: customer password: 123456 #读取本地配置 profiles: active: native eureka: client: service-url: defaultZone: http://customer:123456@192.168.1.105:9760/eureka/ instance: # 配置使用主机名注册服务 #hostname: www.ewsd.cn # 优先使用IP地址方式进行注册服务 prefer-ip-address: true #ip-address: http://www.ewsd.cn #instanceId: ${spring.application.name}:${server.address}:${server.port} management: endpoints: web: exposure: include: "*"
网关Gateway是Spring Cloud官方推出的第二代网关框架,取代Zuul网关。网关作为流量的,在微服务系统中有着非常作用,其作用是路由转发、权限校验、限流控制等作用。
spring: main: allow-bean-definition-overriding: true application: name: gateway cloud: config: discovery: enabled: true service-id: CONFIG profile: dev-liqiang uri: http://192.168.1.105:9780/ eureka: client: service-url: defaultZone: http://customer:123456@192.168.1.105:9760/eureka/ instance: prefer-ip-address: true
http://当前IP地址:9770
该模块为平台基础系统模块即system,必须启动这个基础模块,然后再加载其他选用模块。
spring: application: name: common,system cloud: config: discovery: enabled: true service-id: CONFIG profile: dev-liqiang uri: http://192.168.1.105:9780/ eureka: client: service-url: defaultZone: http://customer:123456@192.168.1.105:9760/eureka/
该模块是平台的主数据中心即mdata,用户登陆以及数据调用都必须依赖此模块,该模块也是本平台基础运行的包。
spring: main: allow-bean-definition-overriding: true application: name: xxl-job,mdata cloud: config: discovery: enabled: true service-id: CONFIG profile: test uri: http://192.168.1.203:9780/ eureka: client: service-url: defaultZone: http://customer:123456@192.168.1.203:9760/eureka/
根据你购买的模块配置相应的配置文件和仓库,然后开始运行即可