<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jetty與maven集成

    自己做個小項目,使用了 maven2 ,一直使用 tomcat ,但很不方便。采用直接改 server.xml 指向項目路徑的方法,但這樣要求把編譯路徑改向 WEB-INF/classes ,而且要求把需要的 jar 放到 WEB-INF/lib 下去。而如果修改了 pom 文件,就需要重新 mvn eclipse:eclipse ,修改項目文件,然后編譯路徑又會變成 target/classes ,然后還需要把 jar 拷到 lib 下去,很是麻煩。嘗試使用 resin ,也是采用 maven 的方式,但官方 maven repository 上只有一個版本,然后需要 jca1.5 ,結果上面又沒有,自己作弊吧,終歸不爽。正好 alin 建議用 jetty ,就按他的文檔嘗試了一下。

    Pom 文件中加上以下依賴,然后 mvn eclipse:eclipse ,會到官方的 repo down 這些 jar ,其中 ant 因為較大( 1M )可能會失敗,可以重試解決。如果這些 jar 的同一版本以前 maven 下過就不會重復下,這也體現了 maven 的一些優勢。

    < dependency >

    ??????????? < groupId > tomcat </ groupId >

    ??????????? < artifactId > jasper-compiler </ artifactId >

    ??????????? < version > 5.5.15 </ version >

    ?????????? < scope > test </ scope > ????????

    ??????? </ dependency >

    ??????? < dependency >

    ??????????? < groupId > tomcat </ groupId >

    ??????????? < artifactId > jasper-runtime </ artifactId >

    ??????????? < version > 5.5.15 </ version >

    ?????????? < scope > test </ scope > ????????

    ??????? </ dependency >

    ?????? < dependency >

    ??????????? < groupId > commons-el </ groupId >

    ??????????? < artifactId > commons-el </ artifactId >

    ??????????? < version > 1.0 </ version >

    ?????????? < scope > test </ scope > ????????

    ??????? </ dependency > ????????????

    ???? ??? < dependency >

    ??????????? < groupId > org.mortbay.jetty </ groupId >

    ??????????? < artifactId > org.mortbay.jetty </ artifactId >

    ??????????? < version > 5.1.10 </ version >

    ?????????? < scope > test </ scope > ????????

    ??????? </ dependency >

    ??????? < dependency >

    ??????????? < groupId > javax.servlet </ groupId >

    ??????????? < artifactId > jsp-api </ artifactId >

    ??????????? < version > 2.0 </ version >

    ?????????? < scope > test </ scope > ????????

    ??????? </ dependency >

    ??????? < dependency >

    ??????????? < groupId > ant </ groupId >

    ??????????? < artifactId > ant </ artifactId >

    ??????????? < version > 1.6.5 </ version >

    ?????????? < scope > test </ scope >

    ??????? </ dependency >

    然后放寫一個 RunJetty.Java ,同包放一個 jetty-config.xml (建議放 test 相關包里)。在 eclipse 里運行 RunJetty ,就啟動 jetty 了,它會使用當前項目的 class loader ,所以不用更改編譯路徑,也不用拷貝 jar 了。 jetty-config 的配置很簡單,大家一看就知道了。具體文件如下:

    import java.net.URL;

    import org.apache.commons.logging.Log;

    import org.apache.commons.logging.LogFactory;

    import org.mortbay.jetty.Server;

    ?

    public class RunJetty {

    ?????? private static Log log = LogFactory.getLog(RunJetty.class);

    ?

    ?????? /**

    ?????? ?* @param args

    ?????? ?*/

    ?????? public static void main(String[] args) {

    ????????????? Server jettyServer = null;

    ????????????? try {

    ???????????????????? URL jettyConfig = RunJetty.class.getResource("jetty-config.xml");

    ???????????????????? if (jettyConfig == null) {

    ??????????????????????????? log

    ????????????????????????????????????????? .fatal("Unable to locate jetty-test-config.xml on the classpath");

    ???????????????????? }

    ???????????????????? jettyServer = new Server(jettyConfig);

    ???????????????????? jettyServer.start();

    ????????????? } catch (Exception e) {

    ???????????????????? log.fatal("Could not start the Jetty server: " + e);

    ???????????????????? if (jettyServer != null) {

    ??????????????????????????? try {

    ?????????????????????????????????? jettyServer.stop();

    ??????????????????????????? } catch (InterruptedException e1) {

    ?????????????????????????????????? log.fatal("Unable to stop the jetty server: " + e1);

    ??????????????????????????? }

    ???????????????????? }

    ????????????? }

    ?????? }

    ?

    }

    ----------------------------------------------?

    <? xml version = "1.0" ?>

    <! DOCTYPE Configure PUBLIC "-//MortBay Consulting//DTD Configure 1.2//EN"

    ??? "http://jetty.mortbay.org/configure_1_2.dtd" >

    < Configure class = "org.mortbay.jetty.Server" >

    ??? < Call name = "addListener" >

    ?????? < Arg >

    ?????????? < New class = "org.mortbay.http.SocketListener" >

    ????????????? < Set name = "Port" type = "int" >

    ????????????????? < SystemProperty name = "jetty.port" default = "80" />

    ????????????? </ Set >

    ?????????? </ New >

    ?????? </ Arg >

    ??? </ Call >

    ??? < Call name = "addWebApplication" >

    ?????? < Arg > / </ Arg >

    ?????? < Arg > web </ Arg >

    ??? </ Call >

    ??? < Set name = "requestsPerGC" type = "int" > 2000 </ Set >

    ??? < Set name = "statsOn" type = "boolean" > false </ Set >

    </ Configure >

    posted on 2006-05-15 11:19 pesome 閱讀(2045) 評論(0)  編輯  收藏 所屬分類: 開源軟件

    <2006年5月>
    30123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

    導航

    統計

    公告

    主要記錄作者在學習java中的每一步足跡。除非特別說明,所有文章均為本blog作者原創,如需轉載請注明出處和原作者,如用于商業目的,需跟作者本人聯系。
    歡迎大家訪問:

    常用鏈接

    留言簿(16)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    相冊

    收藏夾

    java技術

    人間百態

    朋友們的blog

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 日本一区二区三区日本免费| 成人性生交大片免费看午夜a| 亚洲色中文字幕无码AV| 国产好大好硬好爽免费不卡| 亚洲中文无码a∨在线观看| 久久九九兔免费精品6| 亚洲jizzjizz少妇| 亚洲人成色777777在线观看| 男人的天堂亚洲一区二区三区| 一区二区三区在线免费观看视频| 亚洲国产高清视频| 日韩黄色免费观看| 在线a级毛片免费视频| 一级做a爰片性色毛片免费网站| 久久亚洲AV无码精品色午夜麻| 成人性生交视频免费观看| 91大神在线免费观看| 免费一级毛片在线播放视频免费观看永久 | 最近免费字幕中文大全视频| 免费无码又爽又刺激一高潮| 亚洲综合激情五月色一区| 亚洲女初尝黑人巨高清| 亚洲精品国产福利一二区| 久久受www免费人成_看片中文| www成人免费视频| 欧亚一级毛片免费看| 欧洲乱码伦视频免费国产| 成人免费网站久久久| 一级毛片大全免费播放| 一级毛片试看60分钟免费播放| 一级毛片aaaaaa视频免费看| 成年网在线观看免费观看网址| 日韩在线视频线视频免费网站| 日韩大片免费观看视频播放| 一级毛片aa高清免费观看| 成人免费乱码大片A毛片| 亚洲av无码专区国产不乱码| 亚洲最大中文字幕| 亚洲va中文字幕无码久久| 免费成人午夜视频| 成人免费午夜视频|