springcloud服务端和客户端的yml配置

一、服务端:

1、依赖


            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-server
        

2、yml

server:
  port: 8761
eureka:
  instance:
    hostname: 192.168.2.106
    prefer-ip-address: true
  client:
    register-with-eureka: false  ##表示是否将自己注册到Eureka Server,默认是true。
    fetch-registry: false       ##表示是否从Eureka Server获取注册信息,默认为true。
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/chenyun01?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
    username: root
    password: root
  application:
    name: eureka

3、启动le类上加注解:

@EnableEurekaServer

二:Client客户端

1、依赖

 
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
            2.0.0.RELEASE
        

2、yml

server:
  port: 8762
eureka:
#  instanc中的配置是让该服务使用IP注册到注册中心,而不是hostname
  instance:
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ip-address}:${server.port}
  client:
    service-url:
      defaultZone: http://192.168.2.106:8761/eureka/
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/chenyun01?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
    username: root
    password: root
  application:
    name: movie

3、启动le类上加注解:

@EnableEurekaClient

 

你可能感兴趣的:(springcloud)