直接在ECLIPSE中JETTY調試方式

來源:互聯網
上載者:User

Maven2代比1代改進很多,其中主要強調的是--它不僅僅是個依賴包管理器!
開始先要推薦一個專講Maven2的電子書給大家,對MAVEN學習相當有助益:Better Builds with Maven  


下面就專門介紹下Maven2對WEBAPP在管理和調試方面的支援。

1.建立項目

mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp

也可參看這裡

建立要注意遵循MAVEN的目錄結構,尤其要注意源檔案要放在main/java下:



2. POM檔案的配置

這裡要特別注意對resource一節的配置,因為我的SPRING以及WEB相關的XML是放在WEB-INF目錄,為了在unit test的時候也能用,加入了對這些設定檔的引用。相當於加了一個classpath。

這裡還有個插曲:不知為何MAVEN2裡沒有JTA的包,自動下載時會有提示教你如何手工通過命令加入,非常簡單。

JETTY的plugin是為後面用它來調試做準備。

DWR也是目前WEB開發一個熱選。

另外,為使用JAVA5代來編譯,加入了maven-compiler-plugin一節。
< project  xmlns ="http://maven.apache.org/POM/4.0.0"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation ="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
   < modelVersion > 4.0.0 </ modelVersion >
   < groupId > com.exchangebit.nms </ groupId >
   < artifactId > ebnms </ artifactId >
   < packaging > war </ packaging >
   < version > 1.0-SNAPSHOT </ version >
   < name > ebnms Maven Webapp </ name >
   < url > http://maven.apache.org </ url >
      
   < build >
     < finalName > ebnms </ finalName >
    
       < resources >
         < resource >
           < directory > src/main/java </ directory >
           < includes >
             < include > **/*.xml </ include >
           </ includes >
         </ resource >
         < resource >
           < directory > src/main/webapp/WEB-INF </ directory >
           < includes >
             < include > **/*.xml </ include >
             < include > **/log4j.properties </ include >
           </ includes >
         </ resource >
       </ resources >
      
       < plugins >
         < plugin >
           < groupId > org.apache.maven.plugins </ groupId >
           < artifactId > maven-compiler-plugin </ artifactId >
           < configuration >
             < source > 1.5 </ source >
             < target > 1.5 </ target >
           </ configuration >
         </ plugin >
        
       < plugin >
         < groupId > org.mortbay.jetty </ groupId >
         < artifactId > maven-jetty-plugin </ artifactId >
       </ plugin >         
  
       </ plugins >
     </ build >     
      
   < dependencies >
     < dependency >
       < groupId > junit </ groupId >
       < artifactId > junit </ artifactId >
       < version > 3.8.1 </ version >
       < scope > test </ scope >
     </ dependency >
        
     < dependency >
       < groupId > org.hibernate </ groupId >
       < artifactId > hibernate </

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.