在Eureka集群的基础上, 启动多个zuul实例
1. zuul pom.xml
|
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath/>
</parent>
<groupId>net.fsd</groupId>
<artifactId>sfgzuul</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sfgzuul</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
<project.build.directory>target</project.build.directory>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>********+${project.build.directory}\${project.artifactId}-${project.version}.jar</echo>
<echo>${project.basedir}</echo>
<copy overwrite="true" tofile="${project.basedir}\\..\\..\\sfglib\\${project.artifactId}-${project.version}.jar"
file="${project.build.directory}\\${project.artifactId}-${project.version}.jar"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
|
2. application-80.yml
|
eureka.client.serviceUrl.defaultZone=http://localhost:7761/eureka/
server.port=7780
spring.application.name=sfgzuul
zuul.routes.sfgserver.path=/sfgserver/**
zuul.routes.sfgserver.serviceId=sfgserver
zuul.routes.sfgclient.path=/sfgclient/**
zuul.routes.sfgclient.serviceId=sfgclient
spring.main.allow-bean-definition-overriding=true
ribbon.MaxAutoRetries=3
ribbon.MaxAutoRetriesNextServer=0
ribbon.ReadTimeout=5000
ribbon.ConnectTimeout=2000
|
3. application-81.yml
|
eureka.client.serviceUrl.defaultZone=http://localhost:7761/eureka/
server.port=7781
spring.application.name=sfgzuul
zuul.routes.sfgserver.path=/sfgserver/**
zuul.routes.sfgserver.serviceId=sfgserver
zuul.routes.sfgclient.path=/sfgclient/**
zuul.routes.sfgclient.serviceId=sfgclient
spring.main.allow-bean-definition-overriding=true
ribbon.MaxAutoRetries=3
ribbon.MaxAutoRetriesNextServer=0
ribbon.ReadTimeout=5000
ribbon.ConnectTimeout=2000
|
4. project

5. run each instance with STS

6. check instance in Eureka 集群


相关文章:
-
2021-06-19
-
2022-01-11
-
2021-11-14
-
2021-11-14
-
2021-11-24
-
2021-10-14
-
2021-11-14
-
2021-11-14