Python 官方文档:入门教程 => 点击学习
目录Feign如何传实体BeanFeign注入Bean为null,启动报错swagger冲突版本解决方案feignService案例controller注入Feign如何传实体Bea
需要加一个@RequestBody序列化对象
@PostMapping("saveOrder")
@ResponseBody
public void saveOrder(@RequestBody OrderBean orderBean) {
userService.saveOrder(orderBean);
}
接口接收请求也要加一个@RequestBody注解
@PostMapping("saveOrder")
public void saveOrder(@RequestBody OrderBean orderBean);
主要是feign版本和swagger版本冲突,本项目spring cloud 版本为 Finchley.M8
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.5.0</version>
</dependency>
@FeignClient(name = "service-weixin",fallback = OAuthServiceFallBack.class, configuration = FeignConfig.class)
public interface OAuthService {
@RequestMapping(value = "/oauth/getOauth2AuthorizationUrl", method = RequestMethod.GET)
ResultBean<String> getOauth2AuthorizationUrl(@RequestParam("url")String url);
}
@RestController
@RequestMapping("/ticket")
public class TicketController {
@Autowired
private TicketService ticketService;
@Autowired
private OAuthService oAuthService;
...
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: 记一次Feign中实现传实体Bean的问题
本文链接: https://lsjlt.com/news/142753.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0