最近维护一个早期的非maven项目,现在尝试由用Idea 导入eclipse项目,编译、打包已经没有问题,一启动就报错,错误如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [ibatis/ibatis.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [ibatis/sqlmap_common/*-sqlmap.xml] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [ibatis/sqlmap_common/*-sqlmap.xml] cannot be opened because it does not exist
ibatis文件:
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="classpath:ibatis/ibatis-sqlMapConfig.xml" /> <property name="mappingLocations"> <list> <value>classpath:ibatis/sqlmap_common/*-sqlmap.xml</value> <value>classpath:ibatis/sqlmap_system/*-sqlmap.xml</value> <value>classpath:ibatis/sqlmap_example/*-sqlmap.xml</value>
.......
</list>
</property> <property name="dataSource" ref="dataSource" /> </bean>
思考了一下,既然spring beanFactory开始创建bean了,说明classpath是能够识别的,那就是在扫描ibatis配置列表时扫描不到文件了,想到别的项目中用classpath*,又搜索了一下classpath与classpath*,因此换成classpath*后可以正常启动项目。
classpath与classpath*:请参考http://blog.csdn.net/renfufei/article/details/50085183
PS:今天又在修改并整理这个配置,我发现有一个目录是空的,没有xml文件,我就把classpath*的写法注释掉,检查后删除了无用的空目录,再启动就正常了,如果之前的给您带来不便之处,请谅解。