zuul 集群

在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 集群

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值