mybatis-mybatis与spring整合的基本配置
来源:互联网 发布:电脑写小说的软件 编辑:程序博客网 时间:2024/06/05 08:38
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="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"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"><!-- 数据源,使用dbcp --><bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=stdb1"></property><property name="username" value="sa"></property><property name="password" value="hyj84884824"></property><property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property></bean><!-- sqlSessionFactory --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 加载mybatis的配置文件 --><property name="configLocation" value="mybatis/SqlMapConfig.xml"/><!-- 数据源 --><property name="dataSource" ref="dataSource"/></bean><!-- <bean id="UserDao" class="com.itcast.ssm.dao.UserDao"><property name="sqlSessionFactory" ref="sqlSessionFactory"/></bean> --> <!-- mapper配置 <bean id="UserMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"> mapperInterface指定mapper接口 <property name="mapperInterface" value="com.itcast.ssm.mapper.UserMapper"/> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean>--><!-- mapper批量扫描,从mapper包中扫描出mapper接口,自动创建代理对象并在spring容器中注册 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><!-- 指定扫描的包名 --><property name="basePackage" value="com.itcast.ssm.mapper"/><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property></bean></beans>SqlMapConfig.xml:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration><mappers><mapper resource="sqlmap/User.xml"/><!-- <mapper class="com.itcast.ssm.mapper.UserMapper"/> --></mappers></configuration>
阅读全文
0 0
- mybatis-mybatis与spring整合的基本配置
- mybatis 与spring整合配置
- Mybatis-Mybatis与Spring的整合
- MyBatis与Spring的整合
- mybatis与spring的整合
- mybatis与spring的整合
- Spring 与 MyBatis 的整合
- SPRING与MYbatis的整合
- Spring与MyBatis的整合
- spring与mybatis的整合
- mybatis与spring的整合
- MyBatis与Spring的整合
- mybatis整合spring配置
- Spring 整合mybatis配置
- spring整合mybatis配置
- Spring整合配置Mybatis
- spring-mybatis整合配置
- mybatis整合Spring的基本步骤
- UVALive 7525
- docker容器内通过supervisor来守护进程
- FreeRTOS系统配置
- struts2-值栈/ngol语句/s标签
- C++中重载和排序问题的简单写法
- mybatis-mybatis与spring整合的基本配置
- use c++ automatic configure RemoteX USB redirection via modify windows policy group
- Koa2 学习笔记(第四天)
- POj 3026 Borg Maze (bfs求权值的最小生成树)
- Educational Codeforces Round 27 G. Shortest Path Problem?
- Lua 调用其他模块
- Qt学习之路(30): Graphics View Framework
- javascript 深入学习之一
- 常用eharts图表展示方法(内附5个常用样例)