You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于Spring Boot 3是否不再使用openapi-generator-maven-plugin的问询

Spring Boot 3 中仍需使用 openapi-generator-maven-plugin

Spring Boot 3 完全需要用到 openapi-generator-maven-plugin,你看到的官方示例没插件配置是因为它是已经生成好代码的成品项目——插件是用来生成代码的工具,代码生成完成后,插件配置就可以移除或注释,不影响项目运行。

而你看到的 useSpringBoot3 正是这个插件的核心配置项之一,用来告诉生成器要生成适配 Spring Boot 3 的代码(比如兼容 Spring Boot 3 的依赖、注解特性)。这个参数需要在插件的配置块里设置,示例配置如下:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>${openapi-generator.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <!-- 开启Spring Boot3适配 -->
                <useSpringBoot3>true</useSpringBoot3>
                <!-- 其他必要配置:OpenAPI spec文件路径、生成代码的包名等 -->
                <inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
                <generatorName>spring</generatorName>
                <packageName>com.example.petstore</packageName>
            </configuration>
        </execution>
    </executions>
</plugin>

简单总结:插件是代码生成的必备工具,useSpringBoot3是插件的配置参数,二者是配合使用的关系,Spring Boot3场景下依然需要依赖这个插件来生成符合要求的代码。

内容的提问来源于stack exchange,提问作者Amir Choubani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 12:20:05