Java中的类型参数名称未指定错误
使用泛型时,需要在声明和使用泛型的地方指定类型参数的名称,如果忽略了这个步骤,编译器将无法确定泛型类型参数的名称,从而导致"Name for argument of type ljava.lang.Stringl not specified"错误。
代码示例:
指定参数名称:
public String delete(@RequestParam(value = "creationIds") List<Long> creationIds,
@Parameter(hidden = true) User user) {
if (null == user) {
return WrapMapper.error(ErrorCodeEnum.ERROR_TOKEN_EXPIR);
}
}
我这个项目升级版本之后还遇到了另一个错误:Name for argument of type [java.lang.Long] not specified, and parameter name information not found in class file either.
解决方法:指定springboot指定的版本号(版本号根据自己项目版本号指定)