`

SSH整合主要配置文件参考2

阅读更多

最后一个是比较重要的spring的配置文件applicationContext.xml:

<?xml version="1.0" encoding="GBK"?>

<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:p="http://www.springframework.org/schema/p"

    xmlns:tx="http://www.springframework.org/schema/tx"

    xmlns:aop="http://www.springframework.org/schema/aop"

    xmlns:context="http://www.springframework.org/schema/context"

    xsi:schemaLocation="http://www.springframework.org/schema/beans

    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

    http://www.springframework.org/schema/tx 

    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

    http://www.springframework.org/schema/aop 

    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

    http://www.springframework.org/schema/context

    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

 

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

       <property name="driverClassName" value="com.mysql.jdbc.Driver">

       </property>

       <property name="url" value="jdbc:mysql://localhost:3306/xkh"></property>

       <property name="username" value="root"></property>

       <property name="password" value="root"></property>

    </bean>

    <bean id="sessionFactory"

       class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

       <property name="dataSource">

           <ref bean="dataSource" />

       </property>

       <property name="hibernateProperties">

           <props>

              <prop key="hibernate.dialect">

                  org.hibernate.dialect.MySQLDialect

              </prop>

           </props>

       </property>

       <property name="mappingResources">

           <list>

              <value>com/itttop/hibernate/po/Student.hbm.xml</value>

              <value>com/itttop/hibernate/po/Sgroup.hbm.xml</value>

           </list>

       </property>

    </bean>

   

    <!-- 配置事务管理 -->

    <bean id="transactionManager"

       class="org.springframework.orm.hibernate3.HibernateTransactionManager">

       <property name="sessionFactory" ref="sessionFactory"/>

    </bean>

    <aop:config>

       <aop:pointcut id="serviceOperation"

           expression="execution(* com.itttop.dao..*(..))" />

       <aop:advisor pointcut-ref="serviceOperation"

           advice-ref="txAdvice" />

    </aop:config>

    <tx:advice id="txAdvice">

       <tx:attributes>

           <tx:method name="get*" read-only="true" />

           <tx:method name="find*" read-only="true" />

           <tx:method name="save*" />

           <tx:method name="update*" />

           <tx:method name="*delete" />

           <tx:method name="*" />

       </tx:attributes>

    </tx:advice>

   

    <bean id="StudentDAO" class="com.itttop.dao.impl.StudentDAOImpl">

       <property name="sessionFactory">

           <ref bean="sessionFactory" />

       </property>

    </bean>

    <bean id="studentService" class="com.itttop.service.impl.StudentServiceImpl">

       <property name="studentDao" ref="StudentDAO"></property>

    </bean>

    <bean id="SgroupDAO" class="com.itttop.dao.impl.SgroupDAOImpl">

       <property name="sessionFactory">

           <ref bean="sessionFactory" />

       </property>

    </bean>

    <bean id="sgroupService" class="com.itttop.service.impl.SgroupServiceImpl">

       <property name="sgroupDao" ref="SgroupDAO"></property>

    </bean>

   

    <bean id="studentAction" class="com.itttop.struts2.action.StudentAction">

       <property name="studentService" ref="studentService"></property>

       <property name="sgroupService" ref="sgroupService"></property>

    </bean>

</beans>

 

以上代码本人测试过,绝对OK!仅供参考...

分享到:
评论

相关推荐

    SSH2项目整合

    欢迎下载SSH2项目整合.zip 此zip资源包含: 1.SSH2的初始配置文件; 2.SSH2的整合包(SSH2+JSON); 3.SSH2整合后的参考项目(不含包,请自行拷贝)

    SSH框架依架包和配置文件

    SSH框架依架包和配置文件,分开版详细介绍了依赖的日志包,Spring4、Struts2、Hibernate5架包和配置文件,整合版则整合了所有依赖架包和配置文件,可供学习参考

    myEclipse8.5整合SSH步骤(基于操作和配置文件)

    详细介绍myEclipse/8.5中整合SSH(Spring/3.0 Struts/2.1 hibernate/3.3)步骤配图介绍操作步骤,文件配置,包括spring事物配置,hibernate数据库及连接池配置等,内容详尽,有超高参考价值。

    ssh框架整合step by step (springMVC + spring 5.0.4 + hibernate 5.0.12)

    # 事务的织入: 开发时不必再处理SessionFactory、Session等, 只要按配置文件指定的格式对方法进行命名, 即可自动开启/提交事务; # 做了BaseDao的简单封装, 并做了基于BaseDao的增/删/改/查/分页查询等操作的示例(并...

    基于myeclipse 9.0 整合的ssh2Demo

    基于myeclipse 9.0 整合的ssh2Demo 各框架都是myeclipse 9.0 集成的最新的版本 其中配置文件还有模块目录结构都已经分离~ 并有基于Hibernate的分页...并附一参考文档,仅供大家学习交流~共同进步...

    maven构建的ssh全注解框架

    自己刚搭建的,比较简单,大家可以参考下,先配置pom文件,然后是spring和hibernate属性文件的整合,然后是struts和web文件。我用的是tomcat7发布的,需要在maven的setting中设置下server,在tomcat7的conf下tomcat-...

    基于Java和SSH的企业级Web应用开发框架设计源码

    本资源提供了一套基于Java和SSH的企业级Web应用开发框架设计源码,包含2438个文件,其中包括672个JavaScript脚本文件,456个PNG图片文件,354个Java源代码文件,172个GIF图片文件,122个CSS样式文件,101个JSP页面...

    使用Annotation并对DAO层封装具有分页功能的S2SH整合实例_好资源0分送

    此时如果使用基于Annotation的SSH框架很容易转移到Struts+EJB+Spring的项目中,而且使用Annotation,很容易实现0配置,像在这个实例中就一个配置,这样避免了配置文件多而不知所措的情况。 开发步骤 2 环境的集成 2 ...

    基于SSH模拟当当网项目(电子商务平台)

    2) 引入Spring开发包和配置文件 applicationContext-base.xml 定义共同的datasource,sessionFactory applicationContext-dao.xml 定义DAO组件 applicationContext-service.xml 定义Service组件 ...

    Java EE实用开发指南

    然后详细介绍了Hibernate的使用与配置文件的映射关系,并对双向一对多的情况进行了非常详细的介绍;接着带领读者去学习Spring技术,以AOP和IOC的行为注入方式进行非常详细的讲解,以1个SSH2整合并且有增删改查功能的...

    SpringMVC+MyBatis+EasyUI+Shiro资源整合框架

    新搭建的SSM框架(参考文章比较多大部分代码都是从网上学习搭建的),并且在新学的基础上整合了EasyUI 跟 Shiro安全登陆(目前只实现接口+配置文件《没有提供登陆成功后的处理跟权限认证,感兴趣的自己学习下吧!...

    Struts2 + Spring3 + Hibernate3.5 整合(集成测试配套jar包更新构建脚本使用说明)

    此项目整合了目前主流和最前源的web开发技术:采用ehcache实现二级缓存(包含查询缓存);用sf4j及logback(log4j的升级版)记录日志;proxool(据说是dbcp和c3p0三者中最优秀的)做连接池;使用jquery的ajax实现仿...

    Struts2 + Spring3 + Hibernate3.5 整合(实际使用项目,version2)

    此项目整合了目前主流和最前源的web开发技术:采用ehcache实现二级缓存(包含查询缓存);用sf4j及logback(log4j的升级版)记录日志;proxool(据说是dbcp和c3p0三者中最优秀的)做连接池;使用jquery的ajax实现仿...

    java web技术开发大全(最全最新)

    2.2.3 JavaWeb程序的配置文件 2.3 MVC模式与MvC框架 2.3.1 JSP模型1和JSP模型2 2.3.2 Web应用程序需要的基础服务 2.3.3 MVC模式概述 2.3.4 常用的MvC框架 2.4 小结 第3章 Web开发中的客户端技术 3.1 ...

    Git权威指南PDF完整版

    30.5.1 在配置文件中出现的版本库,即时生成/ 433 30.5.2 通配符版本库,管理员通过推送创建/ 434 30.5.3 直接在服务器端创建/ 435 30.6 对 Gitolite 的改进/ 435 30.7 Gitolite 功能拓展/ 436 30.7.1 版本库镜像/ ...

    java web开发技术大全

    2.2.3 JavaWeb程序的配置文件 2.3 MVC模式与MvC框架 2.3.1 JSP模型1和JSP模型2 2.3.2 Web应用程序需要的基础服务 2.3.3 MVC模式概述 2.3.4 常用的MvC框架 2.4 小结 第3章 Web开发中的客户端技术...

    Struts2 + Spring3 + Hibernate3.5 整合(实际使用项目,version3).part3

    此项目整合了目前主流和最前源的web开发技术:采用ehcache实现二级缓存(包含查询缓存);用sf4j及logback(log4j的升级版)记录日志;proxool(据说是dbcp和c3p0三者中最优秀的)做连接池;使用jquery的ajax实现仿...

    Struts2 + Spring3 + Hibernate3.5 整合(实际使用项目,version3).part1

    此项目整合了目前主流和最前源的web开发技术:采用ehcache实现二级缓存(包含查询缓存);用sf4j及logback(log4j的升级版)记录日志;proxool(据说是dbcp和c3p0三者中最优秀的)做连接池;使用jquery的ajax实现仿...

    SWAKES_hassio:家庭助理

    1个vCPU 3GB RAM 40GB硬盘HASSIO主管Docker镜像附加组件ESP首页文件编辑器文件编辑器JupyterLab Lite 玛丽亚数据库蚊子经纪人节点红色终端和SSH整合方式Alexa媒体播放器Belkin WeMo 证书到期deCONZ ESP首页

    spring-boot示例项目

    config|[Spring Cloud Alibaba(二)配置中心多项目、多配置文件、分目录实现](https://github.com/smltq/spring-boot-demo/blob/master/cloud-alibaba/README2.md) Sentinel|[Spring Cloud Alibaba(三)Sentinel...

Global site tag (gtag.js) - Google Analytics