AppFuse 安装

首先下载安装marven,然后就可以使用marven来安装appfuse了。
我现在准备是基于struts2+spring+hibernate来构建项目。在命令提示符里进入某个文件夹,从AppFuse+QuickStart拷贝相应的命令(我选的是basic方式,还没实验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

并做相应的修改,我准备作为第一个实践的项目是CMS,因为是第三次彻底的变更底层架构,所以我命名为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文件都会从网络上下载,这个速度是让人难以忍受的,可以先把appfuse-dependencies-2.0.1.zip下载下来,然后解压到某个文件夹下,然后修改$marven/conf/settings.xml里的相应配置,设置本地资源库。

  <!-- 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><!-- 我电脑上的设置 -->

需要注意的上面的配置里说默认的资源库路径为~/.m2/repository,这是指用户的home目录,但如果这样设置在windows下,会产生一些问题,因为windows的用户目录在C:/Documents and Settings下,而这个目录有空格,所以最好直接指定另外的没有空格的英文路径。
执行上面的命令之后会创建如下的内容

    │  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的密码,如果你接着运行mvn jetty:run-war,会产生需要的一切,并发布到jetty中,你就可以在浏览器里查看运行效果了。[[BR]] 我运行

mvn appfuse:full-source

则会创建数据库,生成相关的代码。代码文件夹结构如下

├─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
│  │      ├─s.c.r.i.p.ts
│  │      │  ├─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

进一步的研究尚未进行,准备以此为依托来建立新的框架结构。因为我对appfuse尚未熟悉,计划的步骤是先在svn里随便建一个项目,然后待大致了解后再正式建立一个项目作为今后所有项目的基础架构。

原文地址:https://www.cnblogs.com/yqskj/p/2990692.html