时间:2022-08-25 10:22:40 | 栏目:JAVA代码 | 点击:次
需要加一个@RequestBody序列化对象
/** * 新增 */ @PostMapping("saveOrder") @ResponseBody public void saveOrder(@RequestBody OrderBean orderBean) { userService.saveOrder(orderBean); }
接口接收请求也要加一个@RequestBody注解
/** * 新增 * @param orderBean */ @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; ...