博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Atitit.mybatis的测试 以及spring与mybatis在本项目中的集成配置说明
阅读量:7231 次
发布时间:2019-06-29

本文共 1553 字,大约阅读时间需要 5 分钟。

Atitit.mybatis的测试  以及springmybatis在本项目中的集成配置说明

 

 

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://www.cnblogs.com/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"/>

    

你可能感兴趣的文章
Hdu-6230 2017CCPC-哈尔滨站 A.Palindrome Manacher 主席树
查看>>
提高javascript编码质量-68-1
查看>>
设计模式开篇 - 简单工厂模式
查看>>
Spring MVC 注解和XML的区别
查看>>
利用Swoole实现PHP+websocket直播,即使通讯代码,及linux下swoole安装基本配置
查看>>
Elastic学习第一天遇到的问题以及添加的一些操作
查看>>
Python lambda介绍
查看>>
BSON与JSON的区别
查看>>
文件系统存储数据,与数据库系统存储数据的差别
查看>>
linux之awk
查看>>
第九章 接口
查看>>
XCode4.2.1 使用NavigationController实现View切换
查看>>
如何让NSURLConnection在子线程中运行
查看>>
es6-Generator
查看>>
Python3.6单例模式报错TypeError: object() takes no parameters的解决方法
查看>>
HTML常用标记(选择性,不全)
查看>>
用一辈子去领悟的22条生活真谛
查看>>
1968: [Ahoi2005]COMMON 约数研究
查看>>
discuz 启用html code 显示问题
查看>>
A1027. Colors in Mars (20)
查看>>