分享

用maven构建Hibernate+Spring+Struts的web工程

 yfm10 2010-03-04

用maven构建Hibernate+Spring+Struts的web工程

 

转自http://www./course/3_program/java/javajs/2008513/115765.html

写这个还是怕以后忘了。作个备案。供学习和改进:
命令行创建webapp项目:
mvn archetype:create -DgroupId=com.actioner.ssh2 -DartifactId=ssh2 -DarchetypeArtifactId=maven-archetype-webapp

会创建一个叫ssh2的maven web工程。
手动补足test及其下的java resources filters等及main下的java目录

mvn -Declipse.workspace=d:\projects eclipse:add-maven-repo

mvn eclipse:eclipse


在eclipse中配置配置好tomcat,并将ssh2.xml文件放到tocmat的conf\catalian\localhost下.ssh2.xml内容如下:
<Context path="/ssh2" docBase="D:\projects\ssh2\target\ssh2" debug="0" privileged="true" reloadable="false" workDir="D:\projects\ssh2\target\ssh2\tmp"></Context>

在eclipse中导入ssh2工程

启动tomcat.在ie中输入url:http://localhost:8080/ssh2
如果出现“Hello World”
则OK!!

继续:
在pom.xml中增加对hibernate3.25.ga spring2.06 struts2.09-core包的依赖。可借助eclipse插件实现

在web.xml中增加struts2框架,并在src\main\resources中增加struts.xml 可以将appfuse项目中的copy过来做为模板
在 web.xml中增加spring框架,并在src\main\resources中增加 ApplicationResources.properties ApplicationResources_zh_CN.properties log4j.xml 等资源文件。均可以将appfuse项目中的copy过来做为模板

applicationContext.xml必须放在src\main\webapp\web-inf下

在applicationContext.xml中一定要设置dataSource和sessionFactory否则会报错。mysql数据库和数据库连接池的依赖包也要加载到pom.xml中

Cannot locate the chosen ObjectFactory implementation: spring 要加载struts2-spring.plugs.jar到pom.xml

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多