applicationContext配置---MyBatis
来源:互联网 发布:淘宝助理价格设置 编辑:程序博客网 时间:2024/06/04 19:01
<!--组件扫描--><context:component-scan base-package="*.*.ssm"></context:component-scan><!--第一步dataSource 第二步sqlSessionFactory 第三步MapperFactoryBean --><!--创建数据源--><context:property-placeholder location="classpath:datasource.properties"></context:property-placeholder><!--读取dataSource文件--><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> <property name="driverClassName" value="${jdbc.driver}"></property></bean><!--自动注入数据源--><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"></bean><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="*.*.ssm.dao"></property></bean><!--MapperScannerConfigurer通过id注入到SqlSessionFactoryBean中--> 第一种<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--指定具有sql映射的dao包 如果注释这行 , 就需要使用下面的单一注入--> <!--运行时才会注入,所有自动注入会报错,单一注入不会报错,他是先注入--> <property name="basePackage" value="com.xsh131.ssm.dao"></property></bean>第二中方式单一注入自动依赖sqlSessionFactoryMapperFactoryBean对BanJiDao接口做一个实现类对象,叫banJiDao,就会注入到impl中单个注入,有几个dao就需要注入几个<bean id="banJiDao" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value="*.*.ssm.dao.BanJiDao"></property></bean>
阅读全文
0 0
- applicationContext配置---MyBatis
- spring ApplicationContext.xml配置mybatis
- MyBatis-Spring配置简单了解-applicationContext.xml
- springMVC+mybatis整合之applicationContext.xml基本配置详解
- springMVC+mybatis整合之applicationContext.xml基本配置详解
- applicationContext.xml整合hibernate mybatis
- Spring配置初始化ApplicationContext
- applicationContext.xml配置
- applicationContext.xml 配置说明
- applicationContext.xml配置分析
- struts2-applicationContext.xml配置
- applicationContext.xml 配置模板
- spring配置初始化applicationcontext
- applicationContext.xml 配置说明
- applicationContext.xml 配置说明
- spring applicationContext.xml配置
- applicationContext.xml 配置方法
- applicationContext.xml 配置说明
- 正则表达式学习
- 进程
- 自定义airline
- 什么是默认构造函数?
- 无主之地2 SaveEdit 使用说明
- applicationContext配置---MyBatis
- AVL树
- python多线程模块threading学习总结
- git入门基础教程以及idea中实战
- 接口中的嵌套实现代码
- 类的静态数据成员在 类内只能声明,定义和初始化必须在类外
- 记录
- SpringMVC学习笔记(七):Ajax用法一(传非对象的数据)
- 如愿以偿获得Google(北京)技术岗工作