赞
踩
一、新建父项目,再加modul
父项目pom.xml
- <!--1.管理 SpringBoot的jar包-->
- <!--SpringBoot-->
- <parent>
- <groupId> org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.2.5.RELEASE</version>
- </parent>
-
- <!--2.管理 SpringCloud的jar包,父项目只管理,不引用-->
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-dependencies</artifactId>
- <version>Hoxton.SR3</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <!--3.这里是所有子项目都可以用的jar包-->
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
- </dependencies>
- <modules>
- <module>springcloud-eureka-server</module>
- <module>springcloud-order-server</module>
- <module>springcloud-user-server</module>
- <module>springcloud-user-common</module>
- <module>springcloud-pay-server</module>
- <module>springcloud-zuul-server</module>
- </modules>
二、eureka
1.pom.xml导入依赖
- <dependencies>
- <!--Eureka服务依赖,包含了Eureka客户端包、Springboot-start-web包-->
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
- </dependency>
- </dependencies>
2.在resources下建application.yml
- server: # Eureka服务端端口号
- port: 1010
-
- eureka: # Eureka配置
- instance: # 定义该服务Ip
- hostname: localhost
- # 从上一次收到心跳之后,等待下一次心跳的时间,也就是服务剔除时间,默认90秒
- lease-expiration-duration-in-seconds: 30
- # 发送心跳时间,默认30秒
- lease-renewal-interval-in-seconds: 10
- client: # Eureka客户端配置
- registerWithEureka: false # 该服务不注册到到注册中心
- fetchRegistry: false # 该服务不拉取注册表
- serviceUrl: # 注册中心地址 http://localhost:1001/eureka/
- defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
- server:
- enable-self-preservation: false # 关闭Eureka自我保护机制
- # 自我保护续约百分比,默认是0.85
- renewal-percent-threshold: 0.85
3.在src/main/java下建cn.zyb.EurekaServerApp
@SpringBootApplicatio
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。