首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >邮递员中的Spring-data-rest测试

邮递员中的Spring-data-rest测试
EN

Stack Overflow用户
提问于 2015-04-20 15:16:41
回答 2查看 1.1K关注 0票数 1

我正在用Spring-data-rest开发一个应用程序。我正在测试来自POSTMAN客户端的POST请求,以测试数据是否插入到我的数据库DB.In中我有一个cartItems表。我可以在发布JSON的同时发布数据,如下所示:商品、购物车和merchandiseType是外键引用。

代码语言:javascript
复制
 {
"rate": 500,
"quantity": 1,
"amount": 500,
"createdAt": "2015-04-12T23:40:00.000+0000",
"updatedAt": "2015-04-14T21:35:20.000+0000",
"merchandise": "http://localhost:8080/sportsrest/merchandises/10",
"cart":"http://localhost:8080/sportsrest/carts/902",
"merchandiseType":"http://localhost:8080/sportsrest/merchandiseTypes/1"
  }

但是,当我像下面这样发布数据时,我得到了错误:我放置了商品JSON,而不是商品的URL,这是我已经测试过的商品请求表JSON:

代码语言:javascript
复制
 {
"rate": 500,
"quantity": 1,
"amount": 500,
"createdAt": "2015-04-12T23:40:00.000+0000",
"updatedAt": "2015-04-14T21:35:20.000+0000",
"merchandise": {
   "id": 4,
   "shortDescription": "white football",
   "rate": 500,
   "updatedAt": "2015-04-24T18:30:00.000+0000",
   "createdAt": "2015-04-20T18:30:00.000+0000",
   "longDescription": "test description for binary 1001",
   "type": "1"
    },
"cart":"http://localhost:8080/sportsrest/carts/902",
"merchandiseType":"http://localhost:8080/sportsrest/merchandiseTypes/1"

}

我收到以下错误:

代码语言:javascript
复制
 {
"cause": {
"cause": {
"cause": null,
"message": "Template must not be null or empty!"
  },
"message": "Template must not be null or empty! (through reference chain:   co.vitti.sports.bean.CartItem[\"merchandise\"])"
 },
 "message": "Could not read JSON: Template must not be null or empty! (through reference chain: co.vitti.sports.bean.CartItem[\"merchandise\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Template must not be null or empty! (through reference chain: co.vitti.sports.bean.CartItem[\"merchandise\"])"
}

有人能帮我解释一下为什么会出现这个错误吗?谢谢。

EN

回答 2

Stack Overflow用户

发布于 2015-04-22 21:01:58

我猜您没有提供内容类型:应用程序/json头。

票数 0
EN

Stack Overflow用户

发布于 2015-05-29 01:23:32

尝试用"@RestResource(exported = false)“注释你的"MerchandiseRepository”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29741460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档