最新消息:

appfuse2.0安装札记

技术 admin 2341浏览 0评论

  需要研究一下新版本的appfuse2.0对struts2+spring+hibernate架构的实现方式,看对于新架构的搭建有无参考价值。appfuse2.0 完全采用了maven来作为项目配置管理工具,与appfuse1.x主要采用ant作为核心工具有很大的差异,记录一下appfuse安装过程,供以后查阅。

1、下载并安装Maven 2.0.8

下载并安装Maven 2.0.8,在环境变量中配置MAVEN_HOME并把maven的bin目录(%MAVEN_HOME%\bin)添加到环境变量PATH中。

假定maven安装到c:\maven下

2、下载appfuse2.0.1并解压appfuse

https://appfuse.dev.java.net/files/documents/1397/77082/appfuse-dependencies-2.0.1.zip

假定解压到d:/program/appfuse-dependencies-2.0.1下。

3、修改%maven_home%/conf/settings.xml

修改settings.xml中的localRepository,指向appfuse的解压目录

<settings>
  <!– localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ~/.m2/repository
   –>
   <localRepository>d:/program/appfuse-dependencies-2.0.1</localRepository>

由于ant 1.7存在的bug(Problem with appfuse:gen in windows ),因此如果用的是ant 1.7,确认一下$USER_HOME/.m2/repository是否存在,不存在手工创建,并把修改后的settings.xml 拷贝到~\.m2\repository下不然在执行后续操作mvn appfuse:full-source时候会报如下错误
java.lang.IllegalArgumentException: When not aligning with a user install you mu
st specify a local repository location using the setLocalRepositoryDirectory( Fi
le ) method.
        at org.apache.maven.embedder.MavenEmbedder.createMavenSettings(MavenEmbe
dder.java:699)
        at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:628)

        at org.appfuse.mojo.installer.InstallSourceMojo.addModuleDependencies(In
stallSourceMojo.java:341)
        at org.appfuse.mojo.installer.InstallSourceMojo.addModuleDependencies(In
stallSourceMojo.java:303)
        at org.appfuse.mojo.installer.InstallSourceMojo.execute(InstallSourceMoj
o.java:142)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:443)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
Goal(DefaultLifecycleExecutor.java:493)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:463)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:278)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ————————————————————————

4、运行如下命令,生成struts2.0的项目

mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.yeeach.framework -DartifactId=myproject

myproject的项目文件生成到%MAVEN_HOME%\conf\myproject下

5、修改c:\maven\conf\myproject\pom.xml里mysql的密码

6、在c:\maven\conf\myproject下运行 mvn jetty:run-war,生成项目的war目录

如果要执行mvn tomcat:run-war,可以安装maven的tomcat plugin,可以参看

http://appfuse.org/display/APF/FAQ#FAQ-useexistingtomcat

可以直接利用mvn jetty:run-war生成的war文件,拷贝到tomcat目录下部署也可以

7、生成appfuse 2.0的代码

mvn appfuse:full-source

8、生成eclipse project

mvn eclipse:eclipse

9、参考文档

一个appfuse的eclipse插件:http://candy4appfuse.sourceforge.net/

http://appfuse.org/display/APF/FAQ#FAQ-useexistingtomcat

Technorati 标签: ,,,,

转载请注明:出家如初,成佛有余 » appfuse2.0安装札记

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址