菜鳥學Java(十九)——WEB項目測試好幫手,Maven+Jetty

來源:互聯網
上載者:User

做WEB開發,測試是一件很費時間的事情。所以我們就應該用更簡單、更快捷的方式進行測試。今天就向大家介紹一個輕量級的容器——jetty。j今天說的etty是Maven的一個外掛程式jetty-maven-plugin,與Maven配合起來使用非常的方便,它的配置也非常的簡單,下面我們就看看它怎麼用吧!


在pom.xml 檔案的<project>標籤下加入如下代碼:

  <build><plugins><plugin><groupId>org.mortbay.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>8.1.10.v20130312</version><configuration><connectors><connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"><port>8888</port></connector></connectors><webAppSourceDirectory>${basedir}/WebContent</webAppSourceDirectory><scanIntervalSeconds>10</scanIntervalSeconds><webAppConfig><contextPath>/${project.artifactId}</contextPath></webAppConfig></configuration></plugin></plugins></build>


這樣配置就算完成了,然後在pom.xml檔案上右擊,指向Run As,選擇Maven build,在彈出的視窗的“Goals”中輸入“jetty:run”,然後點擊“run”。



當出現如下資訊代表jetty啟動成功:

[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 10 seconds.


OK,怎麼樣?很簡單吧,動手試試吧!



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.