首页 > 编程知识 正文

Java三大框架ssm项目案例,ssr工作原理

时间:2023-05-06 15:09:21 阅读:49520 作者:3789

SSM集成要点1. Spring接管Mybatis的Session工厂2 .配置applicationContext以构成2.spring事务

1. Spring接管Mybatis的Session工厂,创建applicationContext.xml以部署外部数据源(连接池)。 Spring为扫描SqlSessionFactory工厂而管理的XML版本=' 1.0 '编码=' utf-8 '? beans xmlns=' http://www.spring框架. org/schema/beans ' xmlns 3360 xsi=' http://www.w3.org/2001/XML方案-实例' xmlns : tx=' http://www.spring framework.org/schema/tx ' xsi 3360方案位置=' 3358 www.bbw beans/spring-beans.xsd http://www.spring帧work.org/schema/tx3358 -1 .数据源配置--bean id=' data source ' class=' com.m change.v2.C3 P0.combopooleddatasource ' property name=60 MySQL ://SSM '/property name=' user ' value=' root '/指示spring创建property name-2.sqlsessionfactory : sqlsessionfactorybean-- bean id=' factory ' class=' org.mybean --3 .构成扫描包:结构, 在SQLMapConfig中配置映射器--- -取代bean class=' org.my batis.spring.mapper.mapperscannerconfigurer ' proogrer ' 默认情况下,设置了beans2.spring的事务mybatis不会自动提交为“setautocommit(false )”,因此必须提交事务才能进行有伤更改! -4.配置事务4.1配置管理员,如果dao层使用的技术是jdbc|muybatis,则使用的管理员:如果DataSourceTransactionManager使用的技术是Hibernate,则在、 要使用的管理员: bean id=' TM ' class=' org.spring framework.JDBC.data source .它是HibernateTransactionManager 4.2事务的注释开关配置rce '//bean tx : annotation-driven transaction-manager=' TM '/3.application cooncol配置Mybatis时,应用程序连接此时存在两个文件,如何选择? 有三种方法。 方式一别写:applicationcontext.XML,

如果直接在springmvc.xml .方法:中定义applicationContext.xml中的配置,则可以为两个文件指定相同的前缀“applicationContext*.xml”。 -初始化参数:加载配置文件----init-param param-namecontextconfiglocation/param-name param-value class path 3360应用程序配置init-param方式三:在springmvc.xml中引入应用程序上下文. XML,在springmvc.xml中引入应用程序上下文. XML,在web.xml中引入spricationcontext.XML - application context.XML----导入资源=' class path : application context.XML ' /! ---或---导入资源=' application context.XML ' /

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。