在阅读了一些关于如何在使用Webflux时摆脱Tomcat的文章之后,我仍然无法使用Netty作为Tomcat的替代品。
因为这是一个涉及不同模块的项目,有一个父pom等。我将在这里发布repo的链接:https://github.com/deviad/clarity
让我知道如果有更多的文件等,你想让我复制粘贴在这里,以便遵守这样的政策。
我感兴趣的模块是clarity-transaction-dispatcher。
我认为问题与Spring Cloud需要Tomcat在某个级别(一些传递依赖项)以便我的中间件(clarity-transaction-dispatcher)与Spring Cloud配置服务器进行对话有关。
因此,我很想知道这个问题是否有任何可能的解决办法。
谢谢你。
我尝试使用@WebFlux注释将tomcat从maven中的一些依赖项中排除,排除SpringMVC自动配置。我也试过:Spring boot启用/禁用带有配置文件的嵌入式tomcat
母体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">
<groupId>com.clarity</groupId>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>clarity-transaction-dispatcher</module>
<module>clarity-eureka-server</module>
<module>clarity-persistence</module>
<module>clarity-config-server</module>
<module>clarity-shared</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<artifactId>clarity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
<jool.version>0.9.14</jool.version>
</properties>
<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>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<version>1.2.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jool</artifactId>
<version>${jool.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- Exclude the Tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>an.awesome</groupId>
<artifactId>pipelinr</artifactId>
<version>0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <!-- or newer version -->
<configuration>
<!-- <compilerVersion>11</compilerVersion> <!– depending on your project –>-->
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
清晰性子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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.clarity</groupId>
<artifactId>clarity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath> <!-- lookup parent from repository -->
</parent>
<properties>
<spring-integration-kafka.version>3.1.4.RELEASE</spring-integration-kafka.version>
<web3j.version>4.2.0</web3j.version>
</properties>
<artifactId>clarity-transaction-dispatcher</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>clarity-transaction-dispatcher</name>
<description>This microservice dispatches transactions from a cryptocurrency server to Hyperledger</description>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.clarity</groupId>
<artifactId>clarity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.clarity</groupId>
<artifactId>clarityshared</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-kafka</artifactId>
<version>${spring-integration-kafka.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-schema</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>${web3j.version}</version>
</dependency>
<dependency>
<groupId>com.aol.cyclops</groupId>
<artifactId>cyclops-validation</artifactId>
<version>7.2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
同一模块的主类:
package com.clarity.transactiondispatcher;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.web.reactive.config.EnableWebFlux;
import java.util.TimeZone;
@SpringBootApplication(exclude = {WebMvcAutoConfiguration.class})
@EnableWebFlux
public class TransactionDispatcherApplication implements InitializingBean {
private void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
@Override
public void afterPropertiesSet() {
started();
}
public static void main(String... args) {
new SpringApplicationBuilder(TransactionDispatcherApplication.class).web(WebApplicationType.REACTIVE).run(args);
}
}
在几乎所有我能想到的地方都排除了Tomcat之后,我仍然使用Tomcat而不是Netty运行该应用程序。
要用Spring-Boot开发微服务并用Netty server运行,需要的依赖项很少。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
在主类中,我们只需要@springbootapplication
。
请相应地更改父级和子级pom.xml。根本不应该有任何spring-boot-starter-web
依赖项。
我有一个要求,在Spring Webflux应用程序中,我需要监听HTTP和HTTPS端口。我可以使用 我不知道如何为Netty添加HTTP侦听器。对于我找到的Tomcat Servlet模型https://dzone.com/articles/enable-httphttps-spring-boot.正在为Netty Webflux寻找类似的设置。
问题内容: 我试图将字符串分成数组并替换为,但无法做到,我也尝试了String.replaceAll这样的东西。 我想提供一个通往JNI的路径,并且它只能以这种方式读取。 问题答案: 在这种情况下不要使用- 这是用正则表达式指定的,这意味着您需要更多的转义。这应该很好: 请注意,由于Java字符串文字中的原因,反斜杠加倍-因此此处涉及的 实际 字符串是“单反斜杠”和“双反斜杠”-而不是双倍和四倍。
在Spring Web中,我使用@PreAuthorize with SpEl来检查当前用户的权限。类似这样的东西: 在RestController中: 现在我尝试使用WebFlux。写入了reactiveCheckPermission。 但是它抛出IllegalStateException("block()/block First()/block Final()是阻塞的,线程并行不支持 将boo
我正在研究一种利用JSON中的替换函数参数的方法。Stringify在JavaScript中为了更改单词大小写(toTop /toLowercase),问题是我的JSON不是直键:value,有些值也是键,它们本身也有值,所以我需要遍历所有键和值,检查值是否也是键,并确保我更改所有键和值的大小写(toTop或toDown)。我知道JSON. Stringify(对象,Replace erFunct
我将创建一个身份验证服务器,它本身与一组不同的Oauth2.0服务器交互。Netty似乎是在这里实现网络部分的一个很好的候选者。但在开始之前,我需要澄清一些关于netty的细节,因为我是新手。例行程序如下: > < li> 服务器接受来自客户端的HTTPS连接。 然后,不关闭第一个连接,它通过HTTPS与远程OAuth2.0服务器建立另一个连接并获取数据 毕竟,服务器将结果发送回客户端,客户端应该
在我的用例中,我有一个带有Reactor Netty的Spring Webflux微服务,我有以下依赖项: null 由于(版本0.7.6版)已包含在最新的(版本2.0.1版)中,因此不能再使用:,请参阅->https://github.com/reactor/reactor-netty/issues/312 我的代码段: 这适用于版本2.0.0.release,但由于升级到版本2.0.1.rel