Spring Cloud探路(一) Erueka服务器的建立
组件名:Netflix Eureka
作用:支撑微服务的自注册、自发现,提供负载均衡能力
开发环境使用IDEA
1.新建Eureka Server,新建maven项目,配置pom.xml
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Camden.SR5</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
</dependencies>
2.新建包及启动类
@SpringBootApplication
@EnableEurekaServer
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class,args);
}
}
3.新建配置文件application.yml
server:
port: 1000
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
spring:
application:
name: eureka-server
这里主要注意我们的服务注册端口是1000
4.运行程序,打开浏览器127.0.0.1:1000
![](https://images2015.cnblogs.com/blog/659823/201703/659823-20170316165102604-338471470.png)
erueka服务器启动成功,目前还未有服务注册
代码:https://github.com/tilv37/eureka-server
文章同时发布在个人博客