您的位置:首页 > 编程语言 > Java开发

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

2016-05-25 00:57 711 查看
Atitit.mybatis的测试  以及spring与mybatis在本项目中的集成配置说明

 

1.1.
Mybatis invoke1

1.2.
Spring的数据源配置2

1.3.
Mybatis配置文件的位置2

 

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"/>

    
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: