ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码
当前位置:首页 >> 数据库 >> MySql >> spring-mybatis myBatis系列之二:以接口方式交互数据

spring-mybatis myBatis系列之二:以接口方式交互数据(2/3)

来源:网络整理     时间:2016-07-26     关键词:spring-mybatis

本篇文章主要介绍了"spring-mybatis myBatis系列之二:以接口方式交互数据",主要涉及到spring-mybatis方面的内容,对于MySql感兴趣的同学可以参考一下: myBatis系列之一:搭建开发环境是采用SqlSession的通用方法并强制转换的方式,存在着转换安全的问题: User user = (Us...




	
		
	

	
	  
		
		
			
			
			
			
		
	  
	

	
		
	

        或在初始化语句中加入: 

sqlSessionFactory.getConfiguration().addMapper(IUserMapper2.class);  

        如下所示:

@BeforeClass
public static void initial() {
	try {
		reader = Resources.getResourceAsReader("Configuration.xml");
		sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
		sqlSessionFactory.getConfiguration().addMapper(IUserMapper2.class);
	} catch (IOException e) {
		log.error("Error thrown while reading the configuration: {}", e);
	} finally {
		if (reader != null) {
			try {
				reader.close();
			} catch (IOException e) {
				log.error("Error thrown while closing the reader: {}", e);
			}
		}
	}
}

3.相应修改上面的测试方法 

spring-mybatis相关图片

spring-mybatis相关文章