如果是Controller实现api接口,在api中已经写了@requestBody和@RequestParam,在controller不想写了,就可以加如下配置
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ValueConstants;
import org.springframework.web.method.annotation.RequestParamMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;
import java.util.List;
/**
* 自定义web配置
*/
@Configuration
public

在Spring Boot中使用Feign实现API接口时,如果接口已定义了@RequestBody和@RequestParam,控制器层可以避免重复声明。通过特定配置,可以在Controller中省略这些注解。

2041

被折叠的 条评论
为什么被折叠?



