使用 EJB 3.0 的包裝應(yīng)用程序要求有類似于 J2EE 平臺。Ejb 組件打包成 jar 文件作為模塊和打包到 ear 文件作為應(yīng)用企業(yè)存檔。主要三個組件的企業(yè)應(yīng)用程序如下。
jar - Java應(yīng)用程序歸檔,包含EJB模塊,EJB客戶端模塊和實(shí)用模塊。
war - Web應(yīng)用程序歸檔,包含Web模塊。
ear -企業(yè)應(yīng)用程序歸檔,包含jar和war模塊。
在NetBeans很容易創(chuàng)建、開發(fā)、計劃和部署J2EE應(yīng)用程序。
在NetBeans IDE中,選擇File > New Project > 文件>新建項(xiàng)目>類別。選擇項(xiàng)目類型,Java EE中 ,項(xiàng)目類型為Enterprise Application企業(yè)應(yīng)用程序 。單擊Next >下一步> button.Enter項(xiàng)目名稱和位置。單擊Finish>按鈕。我們已經(jīng)選擇名稱為EnterpriseApplicaton。
選擇服務(wù)器和設(shè)置。繼續(xù)Create EJB Module 創(chuàng)建EJB模塊和Create Web Application Module 創(chuàng)建Web應(yīng)用程序模塊所提供的默認(rèn)名稱檢查。點(diǎn)擊完成按鈕。 NetBeans 將在項(xiàng)目窗口中創(chuàng)建以下結(jié)構(gòu)
右鍵單擊項(xiàng)目Enterprise Application企業(yè)應(yīng)用程序項(xiàng)目資源管理器,選擇生成。
ant -f D:SVNEnterpriseApplication dist pre-init: init-private: init-userdir: init-user: init-project: do-init: post-init: init-check: init: deps-jar: deps-j2ee-archive: EnterpriseApplication-ejb.init: EnterpriseApplication-ejb.deps-jar: EnterpriseApplication-ejb.compile: EnterpriseApplication-ejb.library-inclusion-in-manifest: Building jar: D:SVNEnterpriseApplicationEnterpriseApplication-ejbdistEnterpriseApplication-ejb.jar EnterpriseApplication-ejb.dist-ear: EnterpriseApplication-war.init: EnterpriseApplication-war.deps-module-jar: EnterpriseApplication-war.deps-ear-jar: EnterpriseApplication-ejb.init: EnterpriseApplication-ejb.deps-jar: EnterpriseApplication-ejb.compile: EnterpriseApplication-ejb.library-inclusion-in-manifest: EnterpriseApplication-ejb.dist-ear: EnterpriseApplication-war.deps-jar: EnterpriseApplication-war.library-inclusion-in-archive: EnterpriseApplication-war.library-inclusion-in-manifest: EnterpriseApplication-war.compile: EnterpriseApplication-war.compile-jsps: EnterpriseApplication-war.do-ear-dist: Building jar: D:SVNEnterpriseApplicationEnterpriseApplication-wardistEnterpriseApplication-war.war EnterpriseApplication-war.dist-ear: pre-pre-compile: pre-compile: Copying 1 file to D:SVNEnterpriseApplicationuild Copying 1 file to D:SVNEnterpriseApplicationuild do-compile: post-compile: compile: pre-dist: do-dist-without-manifest: do-dist-with-manifest: Building jar: D:SVNEnterpriseApplicationdistEnterpriseApplication.ear post-dist: dist: BUILD SUCCESSFUL (total time: 1 second)
在這里,你可以看到,Netbeans的首先準(zhǔn)備jar,然后war最后ear文件Jar和War文件。每個jar、war和ear文件帶有一個meta - inf文件夾根據(jù)J2EE規(guī)范元數(shù)據(jù)。
更多建議: