spring cloud 注册中心的搭建

pom文件

注意:spring cloud server 使用时需要注意parent的版本号和dependencies的版本号,1.3版本的parent请使用Brixton.SR5

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>SpringCloudServer</groupId>
    <artifactId>Spring_Cloud_Server_Two</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>springcloudserver_two</name>
<!--spring cloud server 使用时需要注意parent的版本号和dependencies的版本号-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
        <relativePath/>
    </parent>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <!--<version>Brixton.SR5</version>-->
                <version>Dalston.SR2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
    </dependencies>
</project>

Application.properties文件

注意:为实现服务的高可用,代码中的注释,还是注释掉的好

spring.application.name=springcloudserver
server.port=9090

eureka.instance.hostname=springcloudserver-first
eureka.client.serviceUrl.defaultZone=http://springcloudserver-two:9091/eureka/
## 不向注册中心注册自己
#eureka.client.register-with-eureka=false
## 设置不去检索服务
#eureka.client.fetch-registry=false

主函数类

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer // eureka注册中心
public class ServerApplication_Two {
    public static void main(String[] args) {
        new SpringApplicationBuilder(ServerApplication_Two.class).web(true).run(args);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

菜鸟阿达

成长总是需要时间和经历的

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值