构建父工程-Eureka-Study
引入父依赖
<?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>com.wcy.hand</groupId>
<artifactId>Eureka-Study</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<!-- Eureka-Client子模块-->
<module>Eureka-Client</module>
<!-- Eureka-Server子模块-->
<module>Eureka-Server</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
</parent>
<!--维护版本-->
<dependencyManagement>
<dependencies>
<!--维护spring-cloud版本-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR6</version>
<!--以pom版本引入-->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
创建子模块
选择我们创建的父工程
构建Eureka客户端 --- Eureka-Client
pom文件
<?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">
<parent>
<artifactId>Eureka-Study</artifactId>
<groupId>com.wcy.hand</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Eureka-Client</artifactId>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
配置文件
defaultZone: http://localhost:8761/eureka,http://localhost:8762/eureka,http://localhost:8763/eureka
表示注册到这些Eureka中
server:
port: 8989
spring:
application:
name: eureka-client
eureka:
client:
service-url:
service-url:
defaultZone: http://localhost:8761/eureka,http://localhost:8762/eureka,http://localhost:8763/eureka
# instance:
# lease-expiration-duration-in-seconds: 10 # 修改eureka server默认接受心跳的最大时间 默认90s
# lease-renewal-interval-in-seconds: 5 # 指定客户端多久向服务端发送一次心跳 默认30s
构建Eureka服务端 --- Eureka-Server
pom文件
<?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">
<parent>
<artifactId>Eureka-Study</artifactId>
<groupId>com.wcy.hand</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Eureka-Server</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
</dependencies>
</project>
配置文件
server:
port: 8761
spring:
application:
name: eureka-server
eureka:
client:
service-url:
service-url:
defaultZone: http://localhost:8761/eureka,http://localhost:8762/eureka,http://localhost:8763/eureka
fetch-registry: false
register-with-eureka: false
server:
enable-self-preservation: false # 关闭自我保护
eviction-interval-timer-in-ms: 3000 # 超时3000毫秒清除
集群创建
编辑配置
添加新的SpringBoot
编辑配置SpringBoot信息
选择以及配置
修改端口及应用
点击更多选项
增加虚拟机选项
将你需要修改的端口填入其中
在全部信息保存好后,点击apply应用即可
之后以此点击切换并启动即可
此处评论已关闭