使用appfuse2.1.0-M2建立项目原型骨架的步骤
来源:互联网 发布:普通网民 阿里云能干嘛 编辑:程序博客网 时间:2024/05/19 15:24
使用appfuse2.1.0-M2建立项目原型骨架的步骤
第一步:mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts-archetype -DarchetypeVersion=2.1.0-M2
-DgroupId=cn.xue.app -DartifactId=xue
AppFuse拥有很多构造不同风格项目的能力. 为使用户使用起来更优化、更简单, 我们建立了多种原型(又称作:起始项目). 现在又两种类型的AppFuse 原型:基本的(basic)和模块化的(modular). 基本原型用于建立基于web应用的项目;模块化原型包含“核心”(core)"和"web"模块,用于后台可复用的项目。下表中的命令是用于产生其实项目的,改变groupId就定制包名(package name);改变artifactId来定制项目名(project's name).
官方网址http://appfuse.org/display/APF/AppFuse+QuickStart可以快速的得到命令。
注意:生成的项目多了一层两个webapp文件夹,修改后即可。
第二步: mvn appfuse:full-source (注意和pom.xml文件同级运行)
(由于ant 存在的bug(Problem with appfuse:gen in windows ),因此如果用的是ant ,确认一下$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.)
第三步:mvn eclipse:eclipse
将pom.xml文件中的插件maven-eclipse-plugin的版本从2.7改为2.5.1即可。
第四步:a:调整工程的结构
b: 导入工程后会发现eclipse报"找不到M2_REPO"的错误,其实这是个Eclipse的环境变量,指向你的本地库。把该变量加入eclipse, 方法为一:Window -> Preferences -> Java -> Build Path -> Classpath Variables -> New,Name输入M2_REPO,Path输入E:/apache-maven-2.2.1/m2/repository即可 方法二:设置classpath中的M2_REPO路径。eclipse需要知道本地的maven库。执行下列命令:mvn -Declipse.workspace=C:/Source eclipse:add-maven-repo.如果命令失败,也可以在系统的环境变量里面添加M2_REPO并指定路径
c:修改工程中的pom.xml文件中的数据库密码和用户名.
AppFuse默认使用root用户和空口令,可以编辑项目的pom.xml文件(位于文件末尾)的和 属性,来设置相应的值。现在,运行AppFuse是非常容易得. 一旦建立了原型项目,Maven 就会分别使用hibernate3and dbunit插件来为你建立并设置数据库.需要你做的只是使用Maven来运行Jetty容器并开始浏览应用了. 于是就可以在浏览器输入地址http://localhost:8080来浏览应用了。
默认的管理用户的用户名和口令是dmin/admin,常规用户是user/user。
应该首先把你的项目检入到源码控制服务器中。Google Code提供免费的Subversion 服务, 类似的还有很多
第五步:mvn jetty:run 然后http://127.0.0.1:8080/login.jsp登陆(admin/admin,user/user)
执行“mvn jetty:run-war”时,会清空数据表的数据并插入默认数据,默认数据在%PROJECT_HOME%/src/main/ resources/default-data.xml配置,修改pom.xml中的<dbunit.operation.type>配置为INSERT,UPDATE,DELETE等操作。
第六步:解决appfuse2中DisplayTag中文乱码问题
发现ApplicationResources_zh.properties却无论如何都没有乱码。后来仔细检查pom.xml配置文件,发现ApplicationResources_zh.properties和displaytag_zh.properties对配置还真不一样,原文件对ApplicationResources.properties的相关配置文件是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<configuration>
<dest>target/classes</dest>
<src>src/main/resources</src>
</configuration>
<executions>
<execution>
<id>native2ascii-utf8</id>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<encoding>UTF8</encoding>
<includes>
ApplicationResources_ko.properties,
ApplicationResources_no.properties,
ApplicationResources_tr.properties,
ApplicationResources_zh*.properties
</includes>
</configuration>
</execution>
<execution>
<id>native2ascii-8859_1</id>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<encoding>8859_1</encoding>
<includes>
ApplicationResources_de.properties,
ApplicationResources_fr.properties,
ApplicationResources_nl.properties,
ApplicationResources_pt*.properties
ApplicationResources_zh*.properties
</includes>
</configuration>
</execution>
</executions>
</plugin>
以及——
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>ApplicationResources_de.properties</exclude>
<exclude>ApplicationResources_fr.properties</exclude>
<exclude>ApplicationResources_ko.properties</exclude>
<exclude>ApplicationResources_nl.properties</exclude>
<exclude>ApplicationResources_no.properties</exclude>
<exclude>ApplicationResources_pt*.properties</exclude>
<exclude>ApplicationResources_tr.properties</exclude>
<exclude>ApplicationResources_zh*.properties</exclude>
<exclude>applicationContext-resources.xml</exclude>
<exclude>struts.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
发现一直都没有对关于ApplicationResources以外的*.properties文件进行配置处理,于是照以上看来native2ascii只有对ApplicationResources进行了国际化编码了而已,其他的都没有进行。于是做了一下修改——
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<configuration>
<dest>target/classes</dest>
<src>src/main/resources</src>
</configuration>
<executions>
<execution>
<id>native2ascii-utf8</id>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<includes>
ApplicationResources_ko.properties,
ApplicationResources_no.properties,
ApplicationResources_tr.properties,
*_zh*.properties
</includes>
</configuration>
</execution>
<execution>
<id>native2ascii-8859_1</id>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<encoding>8859_1</encoding>
<includes>
ApplicationResources_de.properties,
ApplicationResources_fr.properties,
ApplicationResources_nl.properties,
ApplicationResources_pt*.properties
</includes>
</configuration>
</execution>
</executions>
</plugin>
以及——
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>ApplicationResources_de.properties</exclude>
<exclude>ApplicationResources_fr.properties</exclude>
<exclude>ApplicationResources_ko.properties</exclude>
<exclude>ApplicationResources_nl.properties</exclude>
<exclude>ApplicationResources_no.properties</exclude>
<exclude>ApplicationResources_pt*.properties</exclude>
<exclude>ApplicationResources_tr.properties</exclude>
<exclude>*_zh*.properties</exclude>
<exclude>applicationContext-resources.xml</exclude>
<exclude>struts.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
注意以上做了蓝字部分的修改
最后重启项目,登录测试,发现一切Ok,后来不管在displaytag对显示属性中作任何修改,乱码都不会出现,看来是彻底解决了。
- 使用appfuse2.1.0-M2建立项目原型骨架的步骤
- 建立和使用Maven项目骨架Archetype
- 建立和使用Maven项目骨架Archetype
- appfuse2.0.2 项目创建步骤
- appfuse2中maven的使用。
- mvn命令建立archetype项目骨架顺序
- 渐统江湖的项目原型/骨架生成工具 -- Maven Archetype
- 使用Archetype生成项目骨架
- Maven骨架的使用
- 在netbeans7.0.1中创建基于AppFuse2.1.0的WEB应用项目
- 建立一个web项目的步骤之一(建立数据库)
- 使用Seam-gen生成基础项目骨架
- Maven使用archetype迅速生成项目骨架
- Maven使用archetype迅速生成项目骨架
- 使用maven命令创建web骨架项目
- Maven学习笔记(八)Maven的入门使用—5.使用Archetype生成项目骨架
- 建立一个简单的Client+WebService项目的步骤
- Maven原型骨架及常见问题
- 关于openGL, openGL ES, openVG及android中2D调用关系的报告
- DECLARE_MESSAGE_MAP()
- Failed to access IIS metabase 完美解决
- jQuery弹出层插件大全
- Android zip文件压缩解压缩
- 使用appfuse2.1.0-M2建立项目原型骨架的步骤
- c语言练习9
- Agile PLM Process Extensions FAQ
- Case Study: The Web Guidelines
- 彻底解决Android中文乱码
- log4net配置写入SQL Server数据库(sqlserver-sqlclient) 并传入自定义业务对象
- 你的知识资产(程序员修炼之道摘录六)
- C/C++ unit testing tools
- 基于 Android NDK 进行 OpenGL ES开发