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

升级Spring Boot3.2与Spring Security6.2.0遇参数名未指定错误

解决Spring Boot 3.2 + Spring Security 6.2.0升级后的参数名缺失错误

问题概述

升级至Spring Boot 3.2与Spring Security 6.2.0后,触发以下错误:

Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.

执行./gradlew check命令或在IDEA中运行测试均会触发该错误。

已尝试的无效操作

  • 按Spring Framework 6.x升级指南,在Gradle Groovy DSL的JavaCompile任务中添加-compilerArgs "-parameters"参数
  • 在IntelliJ IDEA的Java Compiler附加命令行参数中配置-parameters
  • 清理所有构建目录后重新构建项目
  • 使用JDK 17运行项目
  • 升级jakarta.servlet-api至6.1.0-M1

彻底解决方案

1. 统一配置Java编译任务的参数名保留

在根项目的build.gradle中,针对所有Java子项目统一启用参数名编译选项:

subprojects {
    plugins.withType(JavaPlugin) {
        tasks.withType(JavaCompile).configureEach {
            // 两种配置方式二选一,效果一致
            options.parameters = true
            // 或 options.compilerArgs.add("-parameters")
        }
    }
}

关键:必须在plugins.withType(JavaPlugin)块内配置,确保Java插件已应用后再修改编译任务,避免配置失效。

2. 针对Groovy子项目补充配置

如果项目包含Groovy子项目,需额外启用Groovy编译的参数名保留:

subprojects {
    plugins.withType(GroovyPlugin) {
        tasks.withType(GroovyCompile).configureEach {
            groovyOptions.parameters = true
        }
    }
}

可将此配置与Java的配置合并到同一个subprojects块中。

3. 验证配置生效

执行以下命令清理并重新构建项目,验证问题是否解决:

./gradlew clean build check

4. 排查潜在失效点

  • 检查子项目是否单独覆盖了编译配置,导致全局配置被忽略
  • 在IDEA中设置Build, Execution, Deployment > Build Tools > Gradle,将Build and run using和Run tests using均设为Gradle,避免IDE原生构建跳过Gradle配置
  • 确认自定义依赖或第三方库也在编译时添加了-parameters参数,避免依赖传递导致的参数名缺失

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 19:59:51