spring cloud eureka server简单搭建

新建spring boot项目,修改pom文件依赖

org.springframework.boot

spring-boot-starter-parent

1.4.5.RELEASE

org.springframework.cloud

spring-cloud-dependencies

Camden.SR7

pom

import

org.springframework.cloud

spring-cloud-starter-eureka-server

org.springframework.boot

spring-boot-starter-security

org.springframework.boot

spring-boot-devtools

org.springframework.boot

spring-boot-maven-plugin

配置application.yml文件

security:

  basic:

    enabled: true  #开启安全认证

  user:

    name: user    #eureka登录的用户名

    password: password123  #eureka登录的密码

server:

  port: 8761  #eureka链接的端口

eureka:

  client:

    service-url:

      defaultZone: http://user:password123@localhost:8761/eureka  #注册到eureka的地址 #http://localhost:8761/eureka

    register-with-eureka: false #不要把自身注册到eureka  不要把自身单作eureka client 用于单机环境

    fetch-registry: false  #不要获取注册表

spring boot启动类添加如下注解:

@SpringBootApplication //spring boot应用注解

@EnableEurekaServer  //启动eurakaServer,标明该应用为eurekaServer

启动应用,启动成功后在地址栏输入:http://localhost:8761/,看到eureka的界面即可。

你可能感兴趣的:(spring cloud eureka server简单搭建)