1. 該項目不是web項目,所以不存在Deployment Assembly 屬性。在Eclipse中,怎樣將一個非web project變成一個web project。
1)右鍵項目,選擇Project Facets,點擊Convert to faceted from
2) 配置Project Facets
更改Dynamic Web Module的Version為2.5。(3.0為Java7的)。
如果提示錯誤,可能需要在Java Compiler設定Compiler compliance level 為1.6。或者需要在此視窗的Java的Version改成1.6。
3) 配置 Modify Faceted Project
點擊Further configuration available…,彈出Modify Faceted Project視窗
此處是設定web.xml檔案的路徑,我們輸入src/main/webapp。
Generate web.xml deployment descriptor自動產生web.xml檔案,可選可不選。
2. 經過1的project轉換後,應該能夠看到Deployment Assembly出現了,但如果還麼出現,很有可能在Eclipse中Deployment Assembly被disable了,那麼我們需要做的就是將Deployment Assembly選項enable。
在項目所在的工作區間有一個.project檔案,開啟該檔案增加如下這一行用於enable Deployment Assembly屬性。
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
如下面的.project file. Xml代碼 <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>shortbread</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.wst.common.project.facet.core.builder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.google.gdt.eclipse.core.webAppProjectValidator</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.google.gwt.eclipse.core.gwtProjectValidator</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.m2e.core.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>com.google.gwt.eclipse.core.gwtNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> </natures> </projectDescription>
然後重啟Eclipse, 就可在Project的properties中看到Deployment Assembly選項了。
附:設定部署程式集(Web Deployment Assembly)
此處列表是,部署項目時,檔案發布的路徑。
1,我們刪除test的兩項,因為test是測試使用,並不需要部署。
2,設定將Maven的jar包發布到lib下。
Add -> Java Build Path Entries -> Maven Dependencies -> Finish
設定完成效果圖