MyEclipse 在線訂購年終抄底促銷!火爆開搶>>數據庫
MyEclipse最新版下載瀏覽器
使用REST Web Services來管理JPA實體。在逆向工程數據庫表後生成REST Web服務,下面的示例建立用於管理博客條目的簡單Web服務。你將學會:服務器
- 利用數據庫逆向工程開發REST Web服務
- 部署到Tomcat服務器
- 使用REST Web服務資源管理器進行測試
![MyEclipse](http://static.javashuo.com/static/loading.gif)
沒有MyEclipse? 當即下載app
4.部署Web服務應用程序
部署Web服務的最快的方法是使用Run As或Debug As MyEclipse Server Application操做部署項目。eclipse
- 右鍵單擊項目,並選擇Run As>MyEclipse Server Application。
- 選擇MyEclipse Tomcat,而後單擊Finish。
MyEclipse執行如下步驟:工具
- 將項目打包並以爆炸模式將其部署到應用程序服務器
- 啓動應用服務器並加載項目
5.使用REST Web服務資源管理器進行測試
REST Web服務資源管理器在MyEclipse標準訂閱級別不可用。若是您是MyEclipse標準訂戶,請按照使用標準瀏覽器測試Web服務的說明操做。post
- 右鍵單擊項目,並選擇Web服務工具>Test with REST Web Services Explorer。
注意:若是部署到MyEclipse Tomcat之外的應用服務器,則資源管理器中使用的WADL URL可能包含不正確的端口,從而阻止資源管理器加載WADL文件。更正端口,而後單擊Go按鈕繼續。
還能夠經過單擊工具欄上的Web Services Explorer圖標上的下拉箭頭,並選擇Launch REST Web Services Explorer,打開REST Web Services Explorer。在這種狀況下,在繼續以前,必須在地址欄中輸入WADL文件的路徑。
- 將樹展開到count節點,並選擇countREST方法。
![MyEclipse](http://static.javashuo.com/static/loading.gif)
選擇要測試的方法
- 單擊測試方法。將打開一個新選項卡,您能夠在其中輸入信息並運行測試。
![MyEclipse](http://static.javashuo.com/static/loading.gif)
用於測試方法的countREST選項卡
- 單擊運行測試圖標。在Raw響應區域中,觀察計數爲0,由於沒有建立帖子。
- 關閉countREST選項卡。
- 在Post節點中選擇create方法,而後單擊Test method。
- 從create選項卡上的Representation下拉列表中選擇application/xml。
- 在Body中,鍵入application/xml區域,粘貼如下代碼,而後單擊。實體建立成功。
1測試 2spa 3code 4 |
<post> <title data-filtered= "filtered" >My First Post</title> <content>Welcome to my new blog</content> </post> |
![MyEclipse](http://static.javashuo.com/static/loading.gif)
博客條目測試響應
- 關閉create選項卡。
- 選擇countREST方法,並單擊Test method。
- 點擊。計數如今顯示您剛剛發佈的條目的1。
- 在Post節點中,選擇findAll方法,而後單擊Test method。
- 點擊。您能夠在原始視圖中看到您的帖子條目。
![MyEclipse](http://static.javashuo.com/static/loading.gif)