0x03 Spring Cloud 开发手册

1. 服务注册中心

1.1 添加依赖

        <!-- 升级前-->
        <!--
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
        -->
        <!--升级后-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>

1.2.添加注解

启动类添加@EnableEurekaServer注解

@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {

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

1.3. 配置

application.properties

# 服务注册中心应用名称
spring.application.name=eureka-server
# 服务注册中心端口
server.port=1001
# 服务注册中心IP
eureka.instance.hostname=localhost
# 是否开启自身注册为客户端
eureka.client.register-with-eureka=false
# 是否开启自身注册为客户端
eureka.client.fetch-registry=false

1.4 查看控制台

启动工程后,访问:http://localhost:1001/

2. 创建服务提供方

posted @ 2019-03-04 08:53  技术宅星云  阅读(139)  评论(0编辑  收藏  举报