spring-cloud:eureka 客户端搭建

今天搭建了一下eureka的客户端配置,简单记录一下:

1.首先新建一个spring-boot项目,过程省略

2.之后引入jar包,pom文件中<dependencies>标签中加入

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
            <version>1.3.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>

pom中的parent被我改成了这个版本,用以解决搭建后的jar包冲突错误(nosuchmethodException 。。。。bulabula)

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

3.application.properties中添加配置

spring.application.name=spring-cloud-eureka

server.port=8000
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.healthcheck.enabled=true
eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/

这里没有

eureka.client.healthcheck.enabled=true

的话会报错::Parameter 3 of method eurekaRegistration EurekaClientAutoConfiguratio;

这条配置是:开启健康检查(需要spring-boot-starter-actuator依赖)。具体咋回事还没空研究。。留着慢慢看;

4.启动类增加 @EnableEurekaServer配置

@SpringBootApplication
@EnableEurekaServer
public class SpringCloudEurekaApplication {

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

}

5.启动成功后访问 :http://localhost:8000/即可:

以上; 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值