配置nacos及nginx集群的application.yml文件

consumer项目的application.yml配置:

server:
  port: 8180

spring:
  application:
    name: user-consumer
  cloud:
    nacos:
      discovery:
        # 宿主机ip 和 端口
#        server-addr: 192.168.79.128:8848
#        namespace: 22586280-0f6d-441c-9076-278f29e2b3bf
        # 本机ip 和 端口
        server-addr: 127.0.0.1:8848
        # 命名空间的id
        namespace: c466ac9b-3146-477a-9e0a-6e2a37cc080c
        # 分组
        group: 1st
        username: nacos
        password: nacos

#为指定名称的provider配置负载均衡策略, 通常不用
#user-provider:
#  ribbon:
#    NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule
    #WeightedResponseTimeRule, 根据响应权重分配, 可能会超时

provider项目的application.yml配置:

server:
  port: 8280
spring:
  profiles: user1
---
server:
  port: 8281
spring:
  profiles: user2
---
spring:
  application:
    name: user-provider
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://localhost:3306/market?characterEncoding=utf-8
    username: root
    password: 111111
    druid:
      driver-class-name: com.mysql.jdbc.Driver
  cloud:
    nacos:
      discovery:
#        server-addr: 192.168.79.128:8848
#        namespace: 22586280-0f6d-441c-9076-278f29e2b3bf
        server-addr: 127.0.0.1:8848
        namespace: c466ac9b-3146-477a-9e0a-6e2a37cc080c
        group: 1st
        username: nacos
        password: nacos

你可能感兴趣的:(nginx,java,spring)