我这个是基于这个博客的基础上实现mybatis热加载的,但是原博客是基于spring+springmvc+mybatis实现的,我这里是基于spring boot实现,部分实现方法有些改变;
原博客地址:http://thinkgem.iteye.com/blog/2304557
首先整理出几个需要注意的文件:
1:com.xxx.core.mybatis.MapperRefresh;
2:com.xxx.core.mybatis.SqlSessionFactoryBean;
3:mybatis-refresh.properties(在resource目录下);
4:application.yml(resource目录下);
5:com.xxx.core.mybatis.MyBatisConfig。
前面三个文件,是原来旧的spring+springmvc+mybatis架构的工程使用mybatis热加载的时候的三个文件;咩有任何变化,然后下面两个文件,说一下MyBatisConfig,,这个是我新写的一个文件,这个文件的作用相当于以前的在applicationContext.xml文件中配置sqlSessionFactoryBean,现在是手动配置这个bean的来源;最后是yml文件,这个文件中只改了一行代码:
原来的:
mybatis:
typeAliasesPackage: com.xxx.**.model
mapperLocations: classpath*:com/xxx/**/sqlMap/*Mapper.xml
config-location:mybatis-config.xml
现在的:
mybatis:
typeAliasesPackage: com.xxx.**.model
mapperLocations: classpath*:com/xxx/**/sqlMap/*Mapper.xml
configLocation:classpath:mybatis-config.xml
配置好这些文件之后,启动程序之后修改xml文件,日志就应该会出现这一句话这时候热加载就应该是成功了。
相关文件下载地址:
http://download.csdn.net/download/mate_ge/10233769