project facets java轉成web項目

前言:java

  用Eclipse開發項目的時候,把一個Web項目導入到Eclipse裏會變成了一個Java工程,將沒法在Tomcat中進行部署運行。web

  方法:eclipse

  1.找到.project文件,找到裏面的<natures>標籤,查看是否有下面的代碼,沒有則複製進去。.net

  Xml代碼orm

  1. <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
  2. <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
  3. <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>

  注:Java項目中只有下面一句:xml

  Xml代碼ip

  1. <nature>org.eclipse.jdt.core.javanature</nature>

  2.刷新導入的項目開發

  3.在項目上點擊右鍵,進入Properties配置,點擊Project Facets,再點擊Convert to faceted form進入屬性設置:部署

  

  4.勾選Dynamic Web Module和Java,選擇相應的版本,並點擊下方出現的Further configuration available:get

  

  5.修改eclipse默認的WebContent爲WebRoot,並根據本身須要勾選Generate web.xml deployment deor:

  

  

  5.點擊OK-->Apply應用設置,Java項目即轉換爲了Web項目。

  注:若是忘記點擊Further configuration available,即忘記修改WebContent爲WebRoot,

  能夠點擊Deployment Assembly選項,而後將WebContent刪除,將WebRoot添加進去。

  

  

  圖示:

  建立或導入:

  

  修改中:

  

  修改完成:

  

  在Tomcat中運行:

  

  注:

  新建Web項目的步驟相同,惟一的區別在於:

  若要設置WebRoot,只能在Further configuration available中設置,

  不能在Deployment Assembly中設置。

相關文章
相關標籤/搜索