当前位置: 首页 > 知识库问答 >
问题:

带有spring本机的Webflux+安全性-noClassDefFounderRorr:WebMvcConfigurer

梁丘烨
2023-03-14

这是我的依赖项:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.5</version>
        <relativePath />
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.experimental</groupId>
            <artifactId>spring-native</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>9.9</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <!-- Customize Spring Boot classifier, useful in order to avoid a clash between Spring Boot repackaging and native-image-maven-plugin -->
        <classifier/>
        <!-- Customize native-image arguments with this property -->
        <native.build.args></native.build.args>
        <!-- `tiny` builder allows small footprint and reduced surface attack, you can also use `base` (the default) or `full` builders to have more tooling available in the image for an improved developer experience -->
        <!-- TODO Bring back "paketobuildpacks/builder:tiny" before 0.10.0 release -->
        <builder>dmikusa/graalvm-tiny</builder>
        <spring-native.version>0.9.2</spring-native.version>

        <project.encondig>UTF-8</project.encondig>
        <project.build.sourceEncoding>${project.encondig}</project.build.sourceEncoding>
        <project.reporting.outputEncoding>${project.encondig}</project.reporting.outputEncoding>

        <java.version>11</java.version>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.compiler.source>${java.version}</maven.compiler.source>

        <spring-cloud.version>2020.0.2</spring-cloud.version>
        <maven.compiler.plugin.version>2.3.2</maven.compiler.plugin.version>
        <maven.resources.plugin.version>2.6</maven.resources.plugin.version>
        <maven.dependency.plugin.version>2.8</maven.dependency.plugin.version>
        <maven.deploy.plugin.version>2.7</maven.deploy.plugin.version>
        <maven.release.plugin.version>2.5.3</maven.release.plugin.version>
        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>

        <jackson.version>2.12.0</jackson.version>
        <jackson-bom.version>${jackson.version}</jackson-bom.version>
        <jacoco.version>0.8.5</jacoco.version>
        <kotlin.version>1.4.20-RC</kotlin.version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <classifier>${classifier}</classifier>
                        <image>
                            <builder>${builder}</builder>
                            <env>
                                <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
                                <BP_NATIVE_IMAGE_BUILD_ARGUMENTS>${native.build.args}</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
                            </env>
                        </image>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.experimental</groupId>
                    <artifactId>spring-aot-maven-plugin</artifactId>
                    <version>${spring-native.version}</version>
                    <executions>
                        <execution>
                            <id>test-generate</id>
                            <goals>
                                <goal>test-generate</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>generate</id>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.graalvm.nativeimage</groupId>
                    <artifactId>native-image-maven-plugin</artifactId>
                    <version>21.1.0</version>
                    <configuration>
                        <imageName>${project.artifactId}</imageName>
                        <buildArgs>${native.build.args}</buildArgs>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>native-image</goal>
                            </goals>
                            <phase>package</phase>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.experimental</groupId>
                <artifactId>spring-native</artifactId>
                <version>${spring-native.version}</version>
            </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>

    <profiles>
        <!-- Enable building a native image using a local installation of native-image with GraalVM native-image-maven-plugin -->
        <profile>
            <id>native-image</id>
            <properties>
                <!-- Avoid a clash between Spring Boot repackaging and native-image-maven-plugin -->
                <classifier>exec</classifier>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.nativeimage</groupId>
                        <artifactId>native-image-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

共有1个答案

祁鸿晖
2023-03-14

我对此不满意,但这是一个变通办法。在pom.xml文件中添加以下代码:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

并在属性文件中添加以下属性:

spring.main.web-application-type=reactive

 类似资料:
  • 我得到了一个Spring Boot2Reactive Web应用程序,它目前有一个基于JWT的身份验证系统。现在,我想添加一个LDAP后端用于身份验证,并通过Kerberos允许单点登录(SSO)。 似乎Kerberos和LDAP支持目前仅限于webmvc,没有专用的反应版本可用。 由于关于将所有3个组件(WebFlux,LDAP+Kerberos)集成到一个应用程序中的文档非常少,我想问一下是否

  • 问题内容: 我有一个带有身份验证服务的简单REST应用程序。我尝试向其中添加swagger和swagger-ui,但只能在中看到端点。在其中,我仅看到端点组,但是无法扩展任何列表。 在chrome调试中,我看到: 加载资源失败:服务器响应状态为401() 未捕获的TypeError:无法读取未定义的属性’indexOf’ 在带有服务器的终端上: 错误10020-[nio-5001-exec-3]

  • 在服务器上,我添加了一个字符串类型的流量连接: 然后,每当我收到消息时,它就会传播消息: 这些数据来自外部来源,因此传入事件的频率超出了我的控制范围。

  • 正在尝试使用Spring boot webflux设置基于JWT令牌的身份验证。 Spring boot版本:-2.3.0。生成快照 技术堆栈:-Angular 9,Spring boot 2.3.0。BUILD-SNAPSHOT,Spring Security,Spring Security JWT GUI基于angular 9并使用基于表单的身份验证。 需要JWT来调用来自角,也需要调用直接到

  • 我有一个Spring WebFlux安全性,如下所示,并希望使用属性控制CSRF。我如何在这里单独添加CSRF检查?

  • 是否存在将@RequestScope与WebFlux一起使用的模式?我们使用了这里建议的方法(https://www.baeldung.com/spring-bean-scopes),但它给出了以下错误。 没有为作用域名请求注册作用域