web.xml 开启spring <listener >org..ContextLoaderListener</> <context-param>name,value(application-dao application-tx) </>
开启springmvc <servlet > name,class(DispatcherServlet) <init-param>name,value(springmvc.xml) </><servlet/>
<servlet-mapping ></>
springmvc 1 扫描controller注解 2 <mvc:annotation-driven>添加消息转换器及适配器,映射器等3,视图转换器
spring application-dao.xml 1. 注解扫描 排除controller扫描 2. 数据源 3.sessionFactory(下面有dataSourse,hibernateProperties,annotatedClasses注解实体类)
application-tx.xml 1.transctionManager (sessionFactory) 2.<tx:adviceid="txAdvice" transaction-manager="transactionManager">遇见save.*开头的开启事物
3.aop
mybatis.cfg.xml <configuration>
<configuration>
//为了可以在result中类名小写
<package name="com.bjsxt.rbac.vo"/>
<configuration>
<configuration>
一个mapper接口对应一个mapper.xml
mapper接口写接口 mapper.xml配置<mapper namespace="mapper类全路径">
<selete id="方法名' parametertype="参数类型"result="映射的实体类(类名小写)"></>
<>
与ss+hibernate不同点在spring容器中注入sqlsession对象和mybaties的包扫描器即可,<bean id="sqlsessionFactory" class=>
< property name="dataSourse" >
< property name="configLocation" value="mybatis.cfg.xml' >
</>
包扫描器<bean class="...MapperScannerConfigurer'>
<property name="basePackage" value="com.bjsxt.demo.mapper">
<property name="sqlSessionFactoryBeanName' value="sqlSessionFactory'>