当尝试使用postmapping和put request更新mongo db表中的现有条目时,每次尝试更新新条目时都会在表中创建。。
下面是我的代码控制器
@RestController
@RequestMapping("/expenses")
public class mydataExpController {
@PutMapping("/")
public mydataExpense updExpenses(@RequestBody mydataExpense exp){
return expenseServices.updData(exp);
}
服务
@Service
public class ExpenseServices {
@Autowired
mydataExpRepository mydataexprepository;
public mydataExpense updData(mydataExpense exp) {
return mydataexprepository.save(exp);
}
存储库
@Repository
public interface mydataExpRepository extends MongoRepository<mydataExpense, String> {
}
Postman
connection →keep-alive
content-type →application/json
date →Tue, 29 Dec 2020 10:54:51 GMT
keep-alive →timeout=60
transfer-encoding →chunked
每次我执行http://localhost:8080/费用/投入
在数据库中创建一个新条目
暂无答案!
目前还没有任何答案,快来回答吧!