测试环境 - SpringBoot + Eureka环境搭建
Eureka环境搭建
-
下载镜像
docker pull springcloud/eureka
-
运行镜像
docker run -dit --name eureka -p 8080:8761 springcloud/eureka:latest
-
查看网页
IDEA搭建SpringBootgong工程
-
新建Spring Boot工程
-
修改pom文件
1)调整版本为2.0.1.RELEASE<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
2)添加Cloud的相关依赖
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Finchley.SR1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
3)增加相关依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
4)修改项目配置文件,增加eureka相关配置
spring: application: name: omm eureka: client: registerWithEureka: false fetchRegistry: false service-url: defaultZone: http://localhost:8080/eureka server: port: 9090
5)添加启动参数
@EnableEurekaClient
6)启动服务
7)查看注册结果