Eureka服务搭建

本文介绍了如何使用Spring Boot和Spring Cloud Camden.SR6版本搭建一个Eureka服务注册中心,包括配置Spring Boot版本为1.5.7.RELEASE,JDK版本为1.8,并详细展示了application.properties配置文件的设置,以及启动程序的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


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=8086
eureka.instance.hostname=localhost
#让服务注册中心不注册自己
eureka.client.register-with-eureka=false
eureka.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
@SpringBootApplication
public class SpringEurekaApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringEurekaApplication.class, args);
	}
	
}

4. 访问链接

http://localhost:8086/


5. 结果



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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值