报错信息:Could not resolve element type of Iterable type @org.springframework.web.bind.annotation.Re

本文介绍了在使用Spring Cloud Feign时遇到的一个报错,问题在于@RequestParam注解中的List<?>类型未被正确声明。通过修改为具体的泛型类型如List<String>,成功解决了这个问题。修复后的代码确保了参数类型的明确性,避免了编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

**报错信息:**Could not resolve element type of Iterable type @org.springframework.web.bind.annotation.RequestParam java.util.List<?>. Not declared?

Caused by: java.lang.IllegalStateException: Could not resolve element type of Iterable type @org.springframework.web.bind.annotation.RequestParam java.util.List<?>. Not declared?
	at feign.Util.checkState(Util.java:130)
	at org.springframework.cloud.openfeign.support.SpringMvcContract.createTypeDescriptor(SpringMvcContract.java:136)
	at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:298)
	at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:110)
	at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:188)
	at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:66)
	at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:154)
	at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:52)
	at feign.Feign$Builder.target(Feign.java:251)
	at org.springframework.cloud.openfeign.HystrixTargeter.target(HystrixTargeter.java:38)
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:242)
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:271)
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:251)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171)
	... 56 common frames omitted

Process finished with exit code 1

List<?> 泛型没有定义

修改之前的代码:

@DeleteMapping("deleteBatch")
public Result deleteBatch(@RequestParam("videoIdList") List videoList) {
    vodService.removeMoreALiYunVideo(videoList);
    return Result.success();
}

修改之后的代码:

@DeleteMapping("deleteBatch")
public Result deleteBatch(@RequestParam("videoIdList") List<String> videoList) {
    vodService.removeMoreALiYunVideo(videoList);
    return Result.success();
}

其实就是加上就可以啦!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值