0
我創建了所有@Entity
一個@RestController
對象的REST URL被設置正確使用application.peroperties
spring.data.rest.base-path
變量設定爲/api
但對於@RequestMapping("someEndpoint")
它沒有使用變量。@Controller不再使用spring.data.rest.base路徑變量REST URL爲@RequestMapping
例
對於@Entity
類用戶的REST端點位於:
`http://localhost:8081/api/users'
但是當我試圖訪問someEndpoint
:
'http://localhost:8081/api/someEndpoint'
我得到的迴應:
回覆狀態
HTTP/1.1 404 Not Found
身體
"timestamp":1461267817272,"status":404,"error":"Not Found","message":"No message available","path":"/api/someEndpoint"}
取而代之的是REST服務的端點位於
'http://localhost:8081/someEndpoint'
響應:
HTTP/1.1 200 OK
Controller類
@RestController
public class HomeController {
@RequestMapping(value = "/")
public String index() {
return "index";
}
@RequestMapping("someEndpoint")
public Stuff runSomething(
@RequestParam(value = "id", required = true) String id)
我在配置中缺少什麼?
謝謝
謝謝。我有一個Spring Data REST對象的混合體,所以我將同時使用這兩個對象。 – ALM