VFS含义是虚拟文件系统;主要是通过程序能够方便读取本地文件系统、FTP文件系统等系统中的文件资源。
Mybatis中提供了VFS这个配置,主要是通过该配置可以加载自定义的虚拟文件系统应用程序。
一.配置应用
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="vfs" ref="vfs"/>
</bean>
<bean id="vfs" class="com.zzy.vfs.VFSmybatisTest">
<!-- 自定义虚拟文件系统应用程序不做说明,后期单独介绍 -->
</bean>
二.源码分析
1.vfs在源码中加载过程
if (this.vfs != null) {
configuration.setVfsImpl(this.vfs);
}
setVfsImpl(this.vfs) 加载自定义的vfs
2.setVfsImpl(this.vfs)方法源码
public void setVfsImpl(Class<? extends VFS> vfsImpl) {
if (vfsImpl != null) {
this.vfsImpl = vfsImpl;
VFS.addImplClass(this.vfsImpl);
}
}
其中vfsImpl是vfs的实现。
3.VFS相关class所在的包