Spring Cloud 学习笔记

环境的配置

用到了lombok 。需要安装lombok plugin 插件

注意点

新建模块需要设置扫描路径@SpringBootApplication(scanBasePackages = {“com.zdzyc.community”})

@SpringBootApplication(scanBasePackages = {"com.zdzyc.community"})
public class CommunityAuthApplication {

	public static void main(String[] args) {
		SpringApplication.run(CommunityAuthApplication.class, args);
	}
}

Eureka 服务注册发现


server端

spring:
  application:
    name: eureka

eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://localhost:8761/eureka/

client端

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
spring:
  application:
    name: web

多个server端。防止一台挂了。可以用其他的。配置要两两相互注册,


server1端
spring:
  application:
    name: eureka1

eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://localhost:8762/eureka/,http://localhost:8763/eureka/,


server2端
spring:
  application:
    name: eureka2

eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://localhost:8761/eureka/,http://localhost:8763/eureka/,


server3端
spring:
  application:
    name: eureka3

eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/,      


client端,要将全部服务端注册上去
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/,http://localhost:8763/eureka/,
spring:
  application:
    name: web
Loading Disqus comments...
Table of Contents