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

如何在OpenAPI Generator Maven插件中指定特定Spring Boot版本?

解决OpenAPI Generator Maven插件生成代码默认Spring Boot版本与项目不一致的问题

问题场景

使用7.12.0版本的OpenAPI Generator Maven插件生成代码时,流程正常,但插件默认依赖存在漏洞的Spring Boot 3.1.3。即便项目已全局升级到Spring Boot 3.4.4,且多模块父POM也指定了该版本,插件生成的子模块POM仍会沿用3.1.3版本。

解决方案

在插件配置中添加父POM相关参数,强制指定生成代码使用的Spring Boot版本:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>7.12.0</version>
    <executions>
        <execution>
            <!-- 保留原有执行配置 -->
            <configuration>
                <!-- 保留原有插件配置 -->
                <parentGroupId>org.springframework.boot</parentGroupId>
                <parentArtifactId>spring-boot-starter-parent</parentArtifactId>
                <parentVersion>3.4.4</parentVersion>
            </configuration>
        </execution>
    </executions>
</plugin>

添加上述三个参数后,插件生成的子模块POM会自动继承指定的Spring Boot父POM版本,与项目全局版本保持一致,规避旧版本的漏洞风险。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 15:22:04