將java項目從myeclipse匯入eclipse中技巧

來源:互聯網
上載者:User

眾所周知,myeclipse內建了很多實用的外掛程式,正因為這些外掛程式的強大功能,協助web程式猿提高了開發效率,同時也看到了無限明媚的春天!而eclipse給大家的印象則是,綠色軟體,體積小,速度快,介面清爽,這些都是它顯著的優點,當然,它也有缺點,那就是功能相對myeclipse而言比較少。雖然eclipse也可通過擴充外掛程式來增加很多與myeclipse相同的功能,但很多人習慣了拿來主義,自己去折騰這樣或那樣的外掛程式總覺得麻煩,還不如直接安裝myeclipse,一會功夫,全部搞定,接著便可以大展拳腳,開始自己的宏圖大業。不過,我要說的是,那是曾經的eclipse,現在eclipse推出了很多開發版本,無論你是c++,還是java,eclipse都提供了相應的開發版本。比如做java的web開發,eclipse有對應的j2ee版本。當然,蘿蔔青菜各有所愛,每個人都有它喜歡的IDE,並且每個IDE都有它的優點和缺點。就比如我,我喜歡不耗記憶體的,介面漂亮的工具,所以eclipse肯定是我的最愛,尤其愛eclipse中代碼的字型和顏色搭配得很好,看起來很舒服。當然,還有個客觀的原因,那就是開發語言是java,正是因為這個原因,所以當遇到myeclipse的web項目,如果我需要把這個項目直接匯入到我的eclipse工作目錄中,就需要進行一些配置上的修改,如果不修改,項目將無法直接運行。以下是具體步驟:

1、通過eclipse的import方式,將web項目匯入。

2、開啟.project檔案,將原設定檔中的<buildSpec>...</buildSpec><natures>...</natures>部分替換為以下內容:

 

Java代碼 
  1. <buildSpec>  
  2.         <buildCommand>  
  3.             <name>org.eclipse.wst.common.project.facet.core.builder</name>  
  4.             <arguments>  
  5.             </arguments>  
  6.         </buildCommand>  
  7.         <buildCommand>  
  8.             <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>  
  9.             <arguments>  
  10.             </arguments>  
  11.         </buildCommand>  
  12.         <buildCommand>  
  13.             <name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>  
  14.             <arguments>  
  15.             </arguments>  
  16.         </buildCommand>  
  17.         <buildCommand>  
  18.             <name>org.eclipse.jdt.core.javabuilder</name>  
  19.             <arguments>  
  20.             </arguments>  
  21.         </buildCommand>  
  22.         <buildCommand>  
  23.             <name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>  
  24.             <arguments>  
  25.             </arguments>  
  26.         </buildCommand>  
  27.         <buildCommand>  
  28.             <name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>  
  29.             <arguments>  
  30.             </arguments>  
  31.         </buildCommand>  
  32.         <buildCommand>  
  33.             <name>org.eclipse.wst.validation.validationbuilder</name>  
  34.             <arguments>  
  35.             </arguments>  
  36.         </buildCommand>  
  37.         <buildCommand>  
  38.             <name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>  
  39.             <arguments>  
  40.             </arguments>  
  41.         </buildCommand>  
  42.     </buildSpec>  
  43.     <natures>  
  44.         <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>  
  45.         <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>  
  46.         <nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>  
  47.         <nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>  
  48.         <nature>org.eclipse.jdt.core.javanature</nature>  
  49.         <nature>org.eclipse.wst.jsdt.core.jsNature</nature>  
  50.         <nature>org.eclipse.wst.common.project.facet.core.nature</nature>  
  51.     </natures>  

 

3、重新整理項目,項目->右鍵->Properties->Project Facets->Configuration->custom,選擇Java和Dynamic Web Module(注意版本,如果無法確定自己的版本,請從高往低測試)

4、修改.settings目錄(可在navigator視圖下查看)中org.eclipse.wst.common.component檔案的如下內容:

 

Java代碼 
  1. <wb-resource deploy-path="/" source-path="/WebContent"/>  


改為:

 

 

Java代碼 
  1. <wb-resource deploy-path="/" source-path="/WebRoot"/>  

 

5、重新整理項目,然後查看classpath是否有問題。
6、最後,刪除eclipse預設的WebContent目錄,Myeclipse預設的是WebRoot。

 

一切大功告成,自此便可以部署和訪問了。

 

原文地址:http://wangshi-ws.iteye.com/blog/1564351

聯繫我們

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