spring cloud 基本搭建

  • Post author:
  • Post category:其他



spring cloud 基本搭建


如下我们使用eureka体系的spring cloud

以下工作都在project : spring-cloud-eureka-project


1,创建一个注册中心(包括监控中心):sc-eureka-server

在这里插入图片描述

在这里插入图片描述

1)新建一个module: sc-eureka-server
	
2)增加依赖:

	<dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
    
 3)在 application.yml 配置eureka server
 	把 application.properties 改成 application.yml 并添加配置:
 	
 		server:
 			port: 8080
		#eureka server 的配置
		#register-with-eureka:表示该eureka节点不能注册服务
		#fetch-registry:表示该eureka节点不能发现(订阅)服务
		#instance.secure-port-enabled:安全保护机制(端口)关闭
		eureka:
  			client:
    			register-with-eureka: false
    			fetch-registry: false
    		instance:
    			secure-port-enabled: false


 4)在主启动类上增加eureka server注解标签
 
 	@SpringBootApplication
	@EnableEurekaServer
	public class ScEurekaServerApplication {
    	public static void main(String[] args) {
        	SpringApplication.run(ScEurekaServerApplication.class, args);
    	}
	}
	
 5)启动测试类(ScEurekaServerApplication)


2,发布一个服务



版权声明:本文为zengshangchun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。