1. Setup your Development Environment - or follow the steps below if you're a veteran.
a. Download and install JDK 5+ (make sure your JAVA_HOME environment variable points to the
JDK, not a JRE).
b. Download and install MySQL 5.x.
c. Setup a local SMTP server or change mail.properties (in src/main/resources) to use a
different host name - it defaults to "localhost".
d. Download and install Maven 2.0.9+.
其中值得注意的一点是,我使用的是jdk1.6,Maven2.0.9,但是配置到启动jetty的时候,老是出错
HTTP ERROR: 503
SERVICE_UNAVAILABLE
RequestURI=/xmlcrm/Install
Powered by jetty://
原因是我使用的repsitory是以前别人的,它固化的版本是1.5,所以报错
2.Use Struts 2 Basic:
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myapp
3.进入myapp目录,设置mysql,root密码为空,或者做其它相关配置,可参考其它文档
运行:mvn 进行相关数据库创建和其他工作
<amp.genericCore>true</amp.genericCore>改为false
mvn appfuse:full-source 试一下(这步就在这一步,否则mysql配置会出错 )
The good news is creating an "old style" project is now pretty easy. If you create a new project using 2.0-m5+, you can now use: mvn appfuse:full-source This goal will convert your project to use all of AppFuse's source and remove all dependencies on AppFuse. It will also refactor all package names and directories to match your project's groupId. What the full-source plugin does: 1. Exports all sources from Subversion into your project. It reads the dao.framework and web.framework properties to determine what you need. 2. Removes warpath plugin from pom.xml. 3. Calculates dependencies by reading pom.xml files form the various AppFuse modules. It replaces your dependencies with these new ones. The order of the dependencies added is alphabetical based on groupId. 4. Reads properties from the root AppFuse pom.xml and adds the ones that don't exist to your project. 5. Renames packages to match your project's groupId.
4.运行 mvn jetty:run-war
5.view your application in your browser at http://localhost:8080
6.mvn war:inplace(这一步可能很重要,也就是把resource中的文件拷到webapp中 )
7.mvn eclipse:eclipse
8.把工程导入eclipse
有些库文件还要导入到工程,在java bulid path 添加jars
还要导入一些,工程中没有的包,我另一篇文章中有提到
9.java bulid path 把 src/main/webapp删除掉,不删掉,发布的时候,发布不上去
10.m2_repo变量设置为本地的respository
11.添加webapp linksource路径为src/main/webapp,这步可有可无,只是把webapp目录提前了
12.使用myeclipse添加web capabilities,路径指向 src/main/webapp
13.发布工程到tomcat,运行程序,http://localhost:8080/myapp
发布的时候会出错,应该把myapp文件夹只读属性去掉
http://www.blogjava.net/RhythmOfRain/archive/2007/06/29/127017.html
有源码包
新增表的时候,需要设置一些参数,参考:http://blog.csdn.net/zhulin902/archive/2009/02/25/3935536.aspx
关于appfuse2的问题,每次mvn jetty:run 我在mysql表就会被重建
最新的2.0.2中把pom文件里的hbm2ddl和dbunit两个地方屏蔽掉即可。
hbm2ddl会每次重新构建表。dbunit会每次重新populate数据。
hibernate3-maven-plugin:
<execution> <phase>process-test-resources</phase> <goals> <goal>hbm2ddl</goal> </goals> </execution> dbunit-maven-plugin: <execution> <phase>test-compile</phase> <goals> <goal>operation</goal> </goals> </execution
附:ApplicationResources _ zh_CN.properties,在最前面空一行,应该可以编辑