`

基于Struts2+Spring+iBatis的web应用最佳实践系列之七(Demo篇)

阅读更多

终于来到了本系列的最终篇,demo已经制作好,可以在此下载demo.rar

 

在下载和使用demo之前,请确保以下环境被正确安装和配置。

 

jdk,这个就不说了,相信大家都能搞定。

 

maven2,可以去maven的主页下载http://maven.apache.org/download.html,解压后请正确配置maven home,并将maven的bin目录加入到path变量中。

 

将 settings.rar解压后的settings.xml复制到user home/.m2目录下

 

确保mysql数据库正确安装,如果没有可以去http://www.mysql.com/downloads/mysql/下载

 

解压sql.rar,得到demo.sql。在mysql中运行命令mysql> source demo.sql;,将demo数据库表结构导入。

 

配置好本机域名(localhost域名不能够被很好的支持),打开c:\windows\system32\drivers\etc\hosts,在127.0.0.1后面加上新的本机域名demo.meidusa.com。

 

最后解压缩demo.rar,假设解压缩到d:\demo,打开命令行,运行D:\demo\mvn install,maven会编译demo工程并自动下载所需要的jar包文件,第一次运行的时候还会配置autoconfig,然后cd到目录D:\demo\demo-web,运行D:\demo\demo-web\mvn jetty:run,启动jetty,打开浏览器,在地址栏输入http://demo.meidusa.com:8080/demo/signin.action,即可看到登录界面。

 

如果要在eclipse中导入maven工程,可以去下载个m2eclipse插件,安装的Update地址是:http://m2eclipse.sonatype.org/update/

 

下载IbatorPlus eclipse插件,直接解压缩到eclipse目录中即可。在使用的时候请在ibatorConfig.xml中配置好mysql的驱动,在demo中的配置是<classPathEntry location="D:\Temp\mysql-connector-java-5.1.6.jar" />,请自行替换驱动所在目录。可以在这里直接下载mysql-connector-java-5.1.6.jar或者去http://www.mysql.com/downloads/connector/j/下载。

 

因为笔者精力有限,demo制作的粗糙了点,不过并不影响对本系列所涉及的技术或所要表达的思想的演示。

  • sql.rar (785 Bytes)
  • 下载次数: 441
分享到:
评论
11 楼 jjjoken2004 2011-01-18  
出错了:
INFO] Scanning for projects..:pom:2.3' from repository internal-plugin (http://122.224.223.123:8081/nexus/co
tent/groups/internal): Error transferring file: Connection timed out: connect
ownloading:




.
ownloading: http://122.224.223.123:8081/nexus/content/groups/public/org/apache/
aven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugi
:pom:2.3' from repository central (http://122.224.223.123:8081/nexus/content/gr
ups/public): Error transferring file: Connection timed out: connect
ownloading: http://122.224.223.123:8081/nexus/content/groups/internal/org/apach
/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugi
:pom:2.3' from repository internal-plugin (http://122.224.223.123:8081/nexus/co
tent/groups/internal): Error transferring file: Connection timed out: connect
ownloading: http://122.224.223.123:8081/nexus/content/groups/public/org/apache/
aven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugi
:pom:2.3' from repository central (http://122.224.223.123:8081/nexus/content/gr
ups/public): Error transferring file: Connection timed out: connect
ownloading: http://122.224.223.123:8081/nexus/content/groups/internal/org/apach
/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugi
:pom:2.3' from repository internal (http://122.224.223.123:8081/nexus/content/g
oups/internal): Error transferring file: Connection timed out: connect
INFO] ------------------------------------------------------------------------
ERROR] BUILD ERROR
INFO] ------------------------------------------------------------------------
INFO] Error building POM (may not be this project's POM).


roject ID: org.apache.maven.plugins:maven-resources-plugin

eason: POM 'org.apache.maven.plugins:maven-resources-plugin' not found in repos
tory: Unable to download the artifact from any repository

org.apache.maven.plugins:maven-resources-plugin:pom:2.3

rom the specified remote repositories:
central (http://122.224.223.123:8081/nexus/content/groups/public),
internal-plugin (http://122.224.223.123:8081/nexus/content/groups/internal),
internal (http://122.224.223.123:8081/nexus/content/groups/internal)

for project org.apache.maven.plugins:maven-resources-plugin
10 楼 watson243671 2010-02-20  
google 一下,String.isEmpty() is Java 1.6, while JavaFX runtime is restricted to Java 1.5 to be compatible with all systems.您的JDK需要明确一下!
然后我就卸载了自己先前的jdk1.5,重新安装了jdk1.6~重新配置,运行,打开浏览器~ok了!
9 楼 watson243671 2010-02-20  
sorry经过了一番尝试,您的demo还是有bug!
[INFO] [compiler:compile]
[INFO] Compiling 5 source files to D:\demo\demo-web\target\classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
D:\demo\demo-web\src\main\java\com\meidusa\demo\web\action\PostAction.java:[20,55] cannot find symbo
l
symbol  : method isEmpty()
location: class java.lang.String
-------------------------------------------------------------------------------
如果您在本机调试没有问题,是否是按照您的意思,我在本地恢复的时候缺少了什么?
8 楼 pujia12345 2010-02-10  
lcllcl987 写道
所为最佳实践, 建议直接参考appfuse:
http://appfuse.org/
里面有struts, ibatis, hibenate, spring, jsf等组合的最佳实践


冒昧一句:你头像是哪个?
7 楼 kevindude 2010-02-10  
看了楼上建议的appfuse,感觉非常不错,很多想法竟然跟我的不谋而合,不过要在一个框架下集成那么多其他框架的组合未免有点太力不从心了,在使用ibatis的时候需要手工写dao和sqlmap,这还不如直接用ibator生成来的方便。但是用maven来生成项目骨架的思路相当不错,很有借鉴意义,我这里的demo就搞的太复杂了。呵呵,搞的我也有想把自己的这套东西做成一个完整的框架的冲动了。
6 楼 lcllcl987 2010-02-10  
所为最佳实践, 建议直接参考appfuse:
http://appfuse.org/
里面有struts, ibatis, hibenate, spring, jsf等组合的最佳实践
5 楼 peng_joy 2010-02-10  
zcy860511 写道
caoyangx 写道
  

你的头像很“童真”………………服了

同意楼上,我也服了,很恶心
4 楼 zcy860511 2010-02-09  
caoyangx 写道
  

你的头像很“童真”………………服了
3 楼 ynstudio 2010-02-09  
感觉对初学者来说,过于复杂了,我是说运行起来的过程。
2 楼 beingchou 2010-02-09  
maven2~~不会用。。想学学。
1 楼 caoyangx 2010-02-09  
  

相关推荐

Global site tag (gtag.js) - Google Analytics