在Spring Boot中创建代理服务,它监听多个端口,并将GET请求重定向到一个新的URL
请求仍然来自的旧URL-http://localhost:7010/dntservice?cptyxxx=89959623213123和portfolioxxx=03880774324234到新URL-http://wasp-uat-na.net/dntservice?cptyxxx=89959623213123和portfolioxxx=03880774324234
Spring有没有办法可以帮我实现这一点???
到目前为止,使用“https://bitbucket.org/asimio/springboot-tomcat-multiple-ports/src/master/”中的步骤,我可以侦听多个端口,但是在添加spring-cloud-gateway的实现时,我得到了以下错误:
启动ApplicationContext时出错。若要显示条件报告,请在启用“调试”的情况下重新运行应用程序。2021-09-08 17:48:22.944错误22192---[主]O.S.B.D.LoggingFailureAnalysisReporter:
应用程序启动失败
说明:
com.potty.wasp.proxyservice.webservices.GlobalErrorWebExceptionHandler中构造函数的参数2需要一个类型为'org.springframework.http.codec.ServerCodecConfigurer'的bean,但找不到该bean。
<?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.potty.wasp</groupId>
<artifactId>wasp-proxy-service</artifactId>
<version>5.0.0-SNAPSHOT</version>
<description>Proxy service used to route calls to WASP on GKP</description>
<properties>
<project.artifactId>wasp-proxy-service</project.artifactId>
<project.version>5.0.0-SNAPSHOT</project.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<janus.janusweb-j2ee-version-gaia>5.0.0.0</janus.janusweb-j2ee-version-gaia>
<janus.janusweb-j2ee-version>6.0.0.1</janus.janusweb-j2ee-version>
<janus.giam-ip-common.version>14.10.19</janus.giam-ip-common.version>
<commons-beanutils.version>1.9.3</commons-beanutils.version>
<json.version>20140107</json.version>
<spring-data-geode.version>2.1.0.RELEASE</spring-data-geode.version>
<spring-shell.version>1.2.0.RELEASE</spring-shell.version>
<jackson.version>2.9.10.20200103</jackson.version>
<xstream.version>1.4.11.1</xstream.version>
<tomcat.version>9.0.31</tomcat.version>
<sonar.coverage.exclusions>
**/db/model/*,
**/json/model/*,
**/datamodel/**/*,
**/enumeration/*,
**/*Literals.*,
**/*Constants.*
</sonar.coverage.exclusions>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>java</sonar.language>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<jacoco.version>0.8.6</jacoco.version>
<jacoco.skip.instrument>true</jacoco.skip.instrument>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<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>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-jcl</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<type>pom</type>
</dependency>-->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<!--~~~~~~~~~~~~~~~SPRING CLOUD~~~~~~~~~~~~~~~-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${artifactId}-${version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
<configuration>
<skip>${jacoco.skip.instrument}</skip>
</configuration>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
<configuration>
<skip>${jacoco.skip.instrument}</skip>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<skip>${jacoco.skip.instrument}</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
spring-cloud-gateway
就是您正在寻找的
问题内容: 是否可以在一个应用程序中绑定和侦听Linux中的多个端口? 问题答案: 对于您要收听的每个端口,您: 使用创建一个单独的套接字。 将其绑定到适当的端口。 调用套接字,以便它设置一个侦听队列。 那时,您的程序正在侦听多个套接字。为了接受这些套接字上的连接,您需要知道客户端要连接到哪个套接字。就是这样。碰巧的是,我有代码可以完全做到这一点,所以这是一个完整的经过测试的示例,它等待多个套接字
我试图从比特币市场RESTful API中获取不同的JSON。 问题是:我只能将单个GET请求逐个发送到API,因此我无法同时从所有比特币市场获取所有数据。 有没有办法使用Python线程(每个线程使用不同的客户端端口发送GET请求)同时获取多个数据?
本文向大家介绍Springboot启用多个监听端口代码实例,包括了Springboot启用多个监听端口代码实例的使用技巧和注意事项,需要的朋友参考一下 前段时间服务有这么个需求,web端的接口需要有web安全相关的整改,但是对内的接口并不需要。所以服务需要多个端口启动,在此记录下 代码如下 application.yml server: port: ${appPort:8800} addition
2.4 多服务&多监听 2.4.1 在Go代码中声明 假定用户需要创建的Web服务 服务名称 版本号 监听地址 网络类型 读取请求数据超时 写入响应数据超时 myapp1 1.0 0.0.0.0:8080、0.0.0.0:4430 http、https(TLS) 0 0 myapp2 2.0 0.0.0.0:8081、0.0.0.0:4431 http、https(TLS) 0 0 无版本号的服务
假定用户需要创建的Web服务 服务名称 版本号 监听地址 网络类型 读取请求数据超时 写入响应数据超时 myapp1 1.0 0.0.0.0:8080 http 0 0 myapp2 2.0 0.0.0.0:8081 http 0 0 无版本号的服务 func main() { ... app1 := faygo.New("myapp1") app2 := faygo.New("mya
假定用户需要创建的Web服务 服务名称 版本号 监听地址 网络类型 读取请求数据超时 写入响应数据超时 myapp 1.0 0.0.0.0:8080、0.0.0.0:4430、0.0.0.0:4431 http、https(TLS)、https(Let’s Encrypt TLS) 0 0 无版本号的服务 func main() { ... app := faygo.New("myapp"