您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 基于全注解方式的SSH基础框架
这是我为新项目专门搭建的基于全注解方式的SSH基础框架,虽然是老掉牙的的东西,自我感觉很良好,好东西不敢独享,晒晒概述:基于struts2.23+spring2.5.6+hibernate3.6.4+hibernate-generic-dao1.0(除了spring,我整合的都是最新的GA包,hibernate-generic-dao是google项目库中一个开源的basedao,我灰常喜欢,因为我找不到更好更适合我的)项目代码是基于eclipse3.6创建的,很简单,大家直接导入则可运行。1.包结构,源码,测试用例,配置文件一目了然。每个功能模块都在modules包下做开发,配置文件统一在resource管理(基实也没多少配置文件,都用注解嘛)。2.无论阅读哪个web项目代码,我都是先从web.xml开始,项目有什么东西一清二楚。我这里将log4j监听放在第一,我想他应该能够从系统启动开启就能记录我的所有日志(求认证)。第二个监听是proxool数据库连接池,听说很高效,所以果断引入(引入步骤搞得复杂吧,我还重写了监听。一切为了稳定,也好扩展我某日喜欢加入动态切换数据源做准备。呵呵)。OpenSessionInView,我想如果你不喜欢可以摘掉,反正我很喜欢。Struts2指定了自定义的struts.xml文件位置,指定扫描注解的action路径。最后是proxool的可视化图形监控,很棒。?xmlversion=1.0encoding=UTF-8?web-appxmlns:xsi==:web=:schemaLocation=://java.sun.com/xml/ns/javaee/web-app_2_5.xsdid=WebApp_IDversion=2.5display-nameframework/display-namecontext-paramparam-namelog4jConfigLocation/param-nameparam-value/WEB-INF/classes/resources/log4j/log4j.properties/param-value/context-paramcontext-paramparam-namepropertyFile/param-nameparam-value/WEB-INF/classes/resources/hibernate/proxool.properties/param-value/context-paramcontext-paramparam-namecontextConfigLocation/param-nameparam-valueclasspath:resources/spring/applicationContext.xml/param-value/context-param!--log4jListener--listenerlistener-classorg.springframework.web.util.Log4jConfigListener/listener-class/listener!--ProxoolListener--listenerlistener-classorg.chinasb.framework.core.db.ProxoolListener/listener-class/listener!--OpenSessionInViewFilter--filterfilter-nameOpenSessionInViewFilter/filter-namefilter-classorg.springframework.orm.hibernate3.support.OpenSessionInViewFilter/filter-classinit-paramparam-namesingleSession/param-nameparam-valuetrue/param-value/init-param/filterfilter-mappingfilter-nameOpenSessionInViewFilter/filter-nameurl-pattern/*/url-pattern/filter-mapping!--SpringListener--listenerlistener-classorg.springframework.web.context.ContextLoaderListener/listener-class/listener!--CharacterEncodingFilter--filterfilter-nameSetCharacterEncoding/filter-namefilter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-classinit-paramparam-nameencoding/param-nameparam-valueUTF-8/param-value/init-paraminit-paramparam-nameforceEncoding/param-name!--强制进行转码--param-valuetrue/param-value/init-param/filterfilter-mappingfilter-nameSetCharacterEncoding/filter-nameurl-pattern/*/url-pattern/filter-mapping!--延长action中属性的生命周期,--filterfilter-namestruts-cleanup/filter-namefilter-classorg.apache.struts2.dispatcher.ActionContextCleanUp/filter-class/filterfilter-mappingfilter-namestruts-cleanup/filter-nameurl-pattern/*/url-pattern/filter-mapping!--Struts2Filter--filterfilter-namestruts2/filter-namefilter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-classinit-paramparam-nameconfig/param-nameparam-valuestruts-default.xml,struts-plugin.xml,resources/struts/struts.xml/param-value/init-paraminit-paramparam-nameactionPackages/param-nameparam-valueorg.chinasb.framework.modules/param-value/init-param/filterfilter-mappingfilter-namestruts2/filter-nameurl-pattern/*/url-pattern/filter-mapping!--ProxoolMonitoring--servletservlet-nameAdmin/servlet-nameservlet-classorg.logicalcobwebs.proxool.admin.servlet.AdminServlet/servlet-class/servletservlet-mappingservlet-nameAdmin/servlet-nameurl-pattern/admin.html/url-pattern/servlet-mapping!--WelcomeList--welcome-file-listwelcome-fileindex.html/welcome-filewelcome-fileindex.htm/welcome-filewelcome-fileindex.jsp/welcome-file/welcome-file-list/web-app3.applicationContext.xml,我想下面注释得也比较清楚了,如果我写错了或理解错了希望指正。?xmlversion=1.0encoding=UTF-8?beansxmlns=:xsi=:context=:schemaLocation=://://://!--使用annotation--context:annotation-config/!--使用annotation自动注册bean,并检查@Controller,@Service,@Repository注解已被注入--context:component-scanbase-package=org.chinasb.framework.modules/!--hibernate属性配置--context:property-placeholderlocation=classpath:resources/hibernate/hibernate.properties/!--Hibernate配置管理--importresource=applicationContext-persistence.xml//beans4.hiberante配置所需的一些属性,指定方言,开始hibernate缓存等,后面还有一个c3p0的数据连接池属性。你们下载的代码里面,数据源方面我换成了c3p0,因为proxool我配置的是随web启动的,而我又不想改成随spring加载启动。所以我开发中注释掉proxool,以后上线再打开。##hibernatehibernate.dialect=org.hibernate.dialect.MySQLDialecthibernate.show_sql=t
本文标题:基于全注解方式的SSH基础框架
链接地址:https://www.777doc.com/doc-4913987 .html