在完成springboot项目的增加的部分中使用postman发送postjson报错500
postman显示[Java] 纯文本查看 复制代码 "status": 500,
"error": "Internal Server Error",
打断点后发现后端数据可以传进来,但接口好像没实现
启动后没报错,但使用postman发送数据后,控制台显示错误空指针异常
部分代码:[Java] 纯文本查看 复制代码 @Servicepublic class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {
@Override
public Boolean add(Book book) {
book.setUseful(true);
book.setCreateTime(DateTool.getCurrTime());
this.save(book);
return true;
}
}
[Java] 纯文本查看 复制代码 @RestController
@RequestMapping("/book")
public class BookController {
private BookService bookService = new BookServiceImpl();
//增加
@RequestMapping( method = RequestMethod.POST,value = "/save")
public Result save(@RequestBody Book book){
Result result = new Result();
//业务交给业务层service
bookService.add(book);
return result;
}
}
|