初探appfuse 2.0.1
首先下載安裝marven,然后就可以使用marven來安裝appfuse了。
我現(xiàn)在準(zhǔn)備是基于struts2+spring+hibernate來構(gòu)建項(xiàng)目。在命令提示符里進(jìn)入某個(gè)文件夾,從AppFuse+QuickStart拷貝相應(yīng)的命令(我選的是basic方式,還沒實(shí)驗(yàn)module方式)
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject
并做相應(yīng)的修改,我準(zhǔn)備作為第一個(gè)實(shí)踐的項(xiàng)目是CMS,因?yàn)槭堑谌螐氐椎淖兏讓蛹軜?gòu),所以我命名為cms3,包根路徑為com.ynstudio.cms。即為
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.ynstudio.cms -DartifactId=cms3
但如果直接這樣的話,有很多依賴的jar文件都會從網(wǎng)絡(luò)上下載,這個(gè)速度是讓人難以忍受的,可以先把appfuse-dependencies-2.0.1.zip下載下來,然后解壓到某個(gè)文件夾下,然后修改$marven/conf/settings.xml里的相應(yīng)配置,設(shè)置本地資源庫。
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ~/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <localRepository>E:/appfusedeps/repository</localRepository><!-- 我電腦上的設(shè)置 -->
需要注意的上面的配置里說默認(rèn)的資源庫路徑為~/.m2/repository,這是指用戶的home目錄,但如果這樣設(shè)置在windows下,會產(chǎn)生一些問題,因?yàn)閣indows的用戶目錄在C:\Documents and Settings下,而這個(gè)目錄有空格,所以最好直接指定另外的沒有空格的英文路徑。
執(zhí)行上面的命令之后會創(chuàng)建如下的內(nèi)容
│ pom.xml │ README.txt │ └─src ├─main │ ├─java │ │ └─com │ │ └─ynstudio │ │ └─cms │ │ App.java │ │ │ ├─resources │ │ │ applicationContext-resources.xml │ │ │ ApplicationResources.properties │ │ │ ApplicationResources_zh.properties │ │ │ ApplicationResources_zh_CN.properties │ │ │ ApplicationResources_zh_TW.properties │ │ │ default-data.xml │ │ │ ehcache.xml │ │ │ hibernate.cfg.xml │ │ │ jdbc.properties │ │ │ log4j.xml │ │ │ mail.properties │ │ │ sql-map-config.xml │ │ │ struts.xml │ │ │ │ │ └─META-INF │ │ persistence.xml │ │ │ └─webapp │ ├─common │ │ menu.jsp │ │ │ └─WEB-INF │ applicationContext.xml │ menu-config.xml │ urlrewrite.xml │ web.xml │ ├─site │ site.xml │ └─test ├─java │ └─com │ └─ynstudio │ └─cms │ AppTest.java │ └─resources config.xml login.xml sample-data.xml web-tests.xml
然后修改pom.xml里mysql的密碼,如果你接著運(yùn)行mvn jetty:run-war,會產(chǎn)生需要的一切,并發(fā)布到j(luò)etty中,你就可以在瀏覽器里查看運(yùn)行效果了。[[BR]] 我運(yùn)行
mvn appfuse:full-source
則會創(chuàng)建數(shù)據(jù)庫,生成相關(guān)的代碼。代碼文件夾結(jié)構(gòu)如下
├─src │ ├─main │ │ ├─java │ │ │ └─com │ │ │ └─ynstudio │ │ │ └─cms │ │ │ ├─dao │ │ │ │ ├─hibernate │ │ │ │ └─spring │ │ │ ├─model │ │ │ ├─service │ │ │ │ └─impl │ │ │ ├─util │ │ │ └─webapp │ │ │ ├─action │ │ │ ├─filter │ │ │ ├─interceptor │ │ │ ├─listener │ │ │ ├─taglib │ │ │ └─util │ │ ├─resources │ │ │ ├─com │ │ │ │ └─ynstudio │ │ │ │ └─cms │ │ │ │ ├─model │ │ │ │ └─webapp │ │ │ │ └─action │ │ │ └─META-INF │ │ └─webapp │ │ ├─admin │ │ ├─common │ │ ├─decorators │ │ ├─images │ │ ├─scripts │ │ │ ├─calendar │ │ │ │ └─lang │ │ │ └─dojo │ │ ├─styles │ │ │ ├─andreas01 │ │ │ │ └─images │ │ │ ├─calendar-aqua │ │ │ ├─puzzlewithstyle │ │ │ │ └─images │ │ │ └─simplicity │ │ │ └─images │ │ ├─template │ │ │ ├─css_xhtml │ │ │ └─xhtml │ │ └─WEB-INF │ │ └─pages │ │ └─admin │ ├─site │ └─test │ ├─java │ │ └─com │ │ └─ynstudio │ │ └─cms │ │ ├─dao │ │ │ └─hibernate │ │ ├─service │ │ │ └─impl │ │ ├─util │ │ └─webapp │ │ ├─action │ │ ├─filter │ │ └─listener │ └─resources │ ├─com │ │ └─ynstudio │ │ └─cms │ │ └─service │ │ └─impl │ └─META-INF └─target ├─appfuse-data ├─appfuse-data-common ├─appfuse-hibernate ├─appfuse-root ├─appfuse-service ├─appfuse-struts ├─appfuse-web └─appfuse-web-common
進(jìn)一步的研究尚未進(jìn)行,準(zhǔn)備以此為依托來建立新的框架結(jié)構(gòu)。因?yàn)槲覍ppfuse尚未熟悉,計(jì)劃的步驟是先在svn里隨便建一個(gè)項(xiàng)目,然后待大致了解后再正式建立一個(gè)項(xiàng)目作為今后所有項(xiàng)目的基礎(chǔ)架構(gòu)。
轉(zhuǎn)載請標(biāo)明來源,謝謝 http://www.ynstudio.com