Atitit.mybatis的测试 以及spring与mybatis在本项目中的集成配置说明
Atitit.mybatis的测试 以及spring与mybatis在本项目中的集成配置说明
1.1. Mybatis invoke
/AtiPlat_train/src/com/attilax/db/mybatisTO91.java
@SuppressWarnings("all")
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String resource = "com/attilax/db/ibatiascfg.xml";
Reader reader;
reader = Resources.getResourceAsReader(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder()
.build(reader);
SqlSession sqlSession = sqlSessionFactory.openSession();
List li= sqlSession.selectList("getLockTables", 9999999);
// StudentDao studentDao =sqlSession.getMapper(StudentDao.class);
// Student st = studentDao.getstudent(1);
System.out.println( li.size());
List li2= sqlSession.selectList("findRecords"," select 1 as tit ");
System.out.println(core.toJsonStrO88(li2));
}
1.2. Spring的数据源配置
D:\0workspace\AtiPlatf_train\src\applicationContext.xml
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- ati add q213 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${ct.jdbc.driverClassName}" />
<property name="url" value="${ct.jdbc.url}" />
作者:: ★(attilax)>>> 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
1.3. Mybatis配置文件的位置
<!-- 数据访问入口 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:configLocation="classpath:/config/ibatis/sql-map-config.xml" p:dataSource-ref="dataSource"/>
相关文章
- Java的注解机制——Spring自动装配的实现原理
- 04-spring-控制反转
- spring hiberante 集成出现异常 java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor
- Spring boot后台搭建二集成Shiro添加Remember Me
- spring hiberante 集成出现异常 java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor
- NoSQL之Redis(五)--- Redis测试以及其与spring的集成
- Spring中的jdbcTemplate使用方法
- spring boot:spring security给用户登录增加自动登录及图形验证码功能(spring boot 2.3.1)
- spring boot配置dubbo注意事项
- Spring MVC集成Log4j
- Spring注解标签详解@Autowired @Qualifier等 @Slf4j
- Spring读源码系列05----bean的加载---中
- 使用Spring开发和监控线程池服务
- 【项目实战】Spring Boot集成JavaMailSender发送邮件
- Spring工具类:FileCopyUtils、StreamUtils
- Spring Boot 集成日志 logging sl4j
- Spring Boot 集成 Activiti 工作流引擎 极简教程
- Spring+Ibatis集成开发实例
- Spring集成Mybatis配置文件的简单理解
- spring集成mybatis配置多个数据源,通过aop自动切换