W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
使用Spring Boot運(yùn)行時(shí),只需將此依賴(lài)項(xiàng)添加到pom文件即可將存儲(chǔ)庫(kù)公開(kāi)為REST服務(wù):
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency>
如果您希望配置參數(shù)(例如路徑),則可以使用@RepositoryRestResource
批注:
@RepositoryRestResource(collectionResourceRel = "trades", path = "trades") public interface TradeRepository extends DatastoreRepository<Trade, String[]> { }
例如,您可以使用curl http://<server>:<port>/trades
檢索存儲(chǔ)庫(kù)中的所有Trade
對(duì)象,或者通過(guò)curl http://<server>:<port>/trades/<trader_id>
檢索任何特定交易。
您也可以使用curl -XPOST -H"Content-Type: application/json" -d@test.json http://<server>:<port>/trades/
進(jìn)行交易,其中文件test.json
包含Trade
對(duì)象的JSON表示形式。
要?jiǎng)h除交易,您可以使用curl -XDELETE http://<server>:<port>/trades/<trader_id>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: