Eureka服务搭建

来源:互联网 发布:ps相片软件下载 编辑:程序博客网 时间:2024/06/13 22:33


1. 版本

spring-boot版本:

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.7.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent>

JDK版本:1.8


spring-cloud版本:

<!--依赖管理,用于管理spring-cloud的依赖--><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-parent</artifactId><version>Camden.SR6</version><type>pom</type><scope>import</scope><exclusions><exclusion><groupId>org.springframework</groupId><artifactId>spring-test</artifactId></exclusion></exclusions></dependency></dependencies></dependencyManagement>

2. 配置文件:application.properties

server.port=8086eureka.instance.hostname=localhost#让服务注册中心不注册自己eureka.client.register-with-eureka=falseeureka.client.fetch-registry=false# 注册中心地址eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/

3. 启动程序

import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@EnableEurekaServer@SpringBootApplicationpublic class SpringEurekaApplication {public static void main(String[] args) {SpringApplication.run(SpringEurekaApplication.class, args);}}

4. 访问链接

http://localhost:8086/


5. 结果



问题:在第一点版本选择的时候,需要时刻注意各版本兼容问题。



原创粉丝点击