非常形貌: 范例非常陈诉 消息Request processing failed: java.lang.IllegalArgumentException: Name for argument of type [int] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the ‘-parameters’ flag. 形貌服务器碰到一个不测的情况,克制它完成请求。 破例情况
jakarta.servlet.ServletException: Request processing failed: java.lang.IllegalArgumentException: Name for argument of type [int] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the ‘-parameters’ flag. 根本缘故因由。
java.lang.IllegalArgumentException: Name for argument of type [int] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the ‘-parameters’ flag.
问题出现缘故因由:新版本Spring调整了参数
找了一晚上问题地点,发现可能是新版本调整了参数,而spring会主动帮助设置,导致编译时选项“-参数”被禁用。也就是错误信息中的末了提示:Ensure that the compiler uses the ‘-parameters’ flag.
尝试一,在idea编译器中设置指定参数,启用 -parameters 编译器标记:
根据提示,想着试下在编译时做一个配置:
public Type test(@PathVariable int var1, @PathVariable int var2){
...
return type;
}
复制代码
修改后代码:
?
public Type test(@PathVariable(value ="var1") int var1, @PathVariable(value ="var2") int var2){
...
return type;
}
?
复制代码
尝试测试,终于看到了久违的200:
至此,终于在各种尝试中办理了问题。
总结:在做参数传递时,需要多把稳@PathVariable注解的使用,有时严格按照其使用方法也许是一个好的习惯。
参考文章:升级springboot3.2.0报Name for argument of type [java.lang.String] not specified, and parameter name inf-CSDN博客
【已办理】java.lang.IllegalArgumentException: Name for argument of type [java.lang.Integer] not specified-CSDN博客
springMvc:Request processing failed: java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflectio… - 困到很想醒 - 博客园
感谢以上大佬。