spring配置文件如下:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis.xml"/>
</bean>
<!-- dao接口的扫描-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="xblog.dal.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
其中mybatis配置文件mybatis.xml在resources文件夹中,内容如下:
<mappers>
<mapper resource="xblog/dal/mybatis/UserMapper.xml" />
<mappers>
UserMapper.xml放在java源码的xblog.dal.mybatis这个package下,
测试时,出错:
Caused by: java.io.IOException: Could not find resource xblog/dal/mybatis/UserMapper.xml
把UserMapper.xml放在resources目录下,并将mybatis.xml修改为:
就可以通过测试.请问:
如何访问到package目录下的资源.