Spring Cloud探路(一) Erueka服务器的建立

组件名:Netflix Eureka 
作用:支撑微服务的自注册、自发现,提供负载均衡能力

开发环境使用IDEA

1.新建Eureka Server,新建maven项目,配置pom.xml
  1. <parent>
  2. <groupId>org.springframework.cloud</groupId>
  3. <artifactId>spring-cloud-starter-parent</artifactId>
  4. <version>Camden.SR5</version>
  5. </parent>
  6. <dependencies>
  7. <dependency>
  8. <groupId>org.springframework.cloud</groupId>
  9. <artifactId>spring-cloud-starter</artifactId>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.springframework.cloud</groupId>
  13. <artifactId>spring-cloud-starter-eureka-server</artifactId>
  14. </dependency>
  15. </dependencies>

2.新建包及启动类
  1. @SpringBootApplication
  2. @EnableEurekaServer
  3. public class Application {
  4. public static void main(String[] args){
  5. SpringApplication.run(Application.class,args);
  6. }
  7. }

 3.新建配置文件application.yml
  1. server:
  2. port: 1000
  3. eureka:
  4. instance:
  5. hostname: localhost
  6. client:
  7. register-with-eureka: false
  8. fetch-registry: false
  9. spring:
  10. application:
  11. name: eureka-server
这里主要注意我们的服务注册端口是1000

4.运行程序,打开浏览器127.0.0.1:1000
 
erueka服务器启动成功,目前还未有服务注册

代码:https://github.com/tilv37/eureka-server





posted @ 2017-03-16 16:51  二刀  阅读(2132)  评论(0编辑  收藏  举报