首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Webflux + spring本机安全性- NoClassDefFoundError: WebMvcConfigurer

Webflux + spring本机安全性- NoClassDefFoundError: WebMvcConfigurer
EN

Stack Overflow用户
提问于 2021-05-06 08:04:57
回答 1查看 1K关注 0票数 1

这是关于春天本地人,我面临着同样的问题,在每一个网络流量项目,我正在工作。我无法生成本地图像。有人能帮忙吗?

我正在开发一个Mac (Catalina10.15.6 (19G73)),并使用OpenJDK Runtime Environment GraalVM CE 21.0.0.2 (构建11.0.10+8-jvmci-21.0-b06)。

我得到的错误是:

org/springframework/web/servlet/config/annotation/WebMvcConfigurer:致命error:java.lang.NoClassDefFoundError

错误:图像生成请求失败,退出状态1

这是我的依赖关系:

代码语言:javascript
复制
    <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>
EN

回答 1

Stack Overflow用户

发布于 2021-05-06 21:31:33

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

代码语言:javascript
复制
    <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>

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

type应用程序类型=反应性

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67414158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档