具体步骤:
1、下载jdk,maven,mysql5.x.设置好环境变量。新建一个存放项目的文件夹。
2、运行:(进入项目目录)
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=org.soft.app -DartifactId=appfuse
3、运行:mvn integration-test(进入项目目录)
4、运行:mvn jetty:run-war (进入项目目录)
5、运行:mvn appfuse:full-source。(出错的解决办法见下面)
注意:
1.在创建完struts2Basic后,cd 到/struts2Basic, 运行命令“mvn appfuse:full-source”,产生如下错误:
AppFuse官方网站QuickStart有解释:
Bug with Ant 1.7.0
Local repositories and projects on Windows platforms are held in directories whose paths contain no spaces.
在...\maven\apache-maven-2.0.8\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>
-->
上面的配置里默认的资源库路径为~/.m2/repository, Documents and Settings里面有空格所以报错。最好直接指定另外的没有空格的英文路径:
<localRepository>E:\appfuse\repository </localRepository>
需要注意的是:也可以设置成这样<localRepository>E:/appfuse/repository </localRepository>
关键在于:最后的目录必须是repository,否则还是报路径错误,我曾建Repository目录,一直报路径不对,找不到*.jar
2. 然后修改pom.xml里mysql的密码,如果你接着运行mvn jetty:run-war,会产生需要的一切,并发布到jetty中,你就可以在浏览器里查看运行效果了。
3.另外
执行mvn eclipse:eclipse,可以生成eclipse下的项目。导入到eclipse后会存在找不到包的问题,需要在eclipse中window-> preference->java->build path->classpath variables中增加M2_REPO指向maven repository的目录。然后编译就可以通过了。
Appfuse 2.0 has finally been released. Instead of using version 1.9.4 (the previous stable release) for an upcoming web project, I decided to use this latest version. The fastest way to learn this new version is through the Quick Start guide. I encountered errors while following this guide. I googled around and found the fixes. For those starting with Appfuse 2.0, here's a list of errors I encountered and what I did to fix them. Note: I may not be able to explain why the fixes fixed the errors.
Error: Executed 'mvn' command and got a 'Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher'.
Fix: Set a M2_HOME environment variable. This should point to your Maven directory. Also, be sure you have JAVA_HOME setup. Appfuse 2.0 requires Maven 2.0.6+ and Java 5+.
Error: After fixing the above error, I got a "Error while expanding /tmp/cargo/installs/apache-tomcat-6.0.14.zip Unexpected end of ZLIB input stream"
Fix: Delete all files inside /tmp/cargo/installs/ (or whatever directory indicated in your case) and manually download apache-tomcat-6.0.14.zip and put it there.
Error: Executed 'mvn jetty:run-war' and got a "Failed startup of context org.mortbay.jetty.webapp.WebAppContext@4d342f5b
{/,jar:file:/.../.../.../.../web/target/..-webapp-1.0-SNAPSHOT.war!/}
java.util.zip.ZipException: error in opening zip file"
Fix: Delete everything inside ~/.m2/repository and execute the command again. This will download everything again.
I hope this post helps you. If you have other errors you encountered, please share how you fixed them. Thanks!
Posted by Milo Felipe at 9:18 AM