Spring Cloud 学习系列:(二)微服务的注册与发现——Eureka - 创建module->
pom
import
org.springframework.boot 拼多多帮助力入口
spring-boot-maven-plugin
2、然后创建两个moudle工程,一个moudle工程作为服务注册中心,即Eureka Server,另一个作为Eureka Client。
Eureka Server
2.1、右键工程->创建module->选择spring initialir 如下图:
2.2、填好自己的项目名
2.3、选择cloud discovery->eureka server ,然后一直下一步就行了。
2.4、创建完后的工程,其pom.xml继承了父pom文件,并引入spring-cloud-starter-netflix-eureka-server的依赖,代码如下:
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd”>
4.0.0
com.riemann
microservice-eureka
0.0.1-SNAPSHOT
com.riemann
microservice-eureka-server
0.0.1-SNAPSHOT
microservice-eureka-server
Eureka Server
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
2.5、启动一个服务注册中心,只需要一个注解@EnableEurekaServer,这个注解需要在springboot工程的启动application类上加:
package com.riemann.microserviceeurekaserver;
import
精彩文章