在将Java工程转maven工程的时候,Java文件夹下的所有sqlMap.xml文件,启动项目的时候无法找到资源,第一时间,去看配置文件,spring有没有启动加载扫描,applicationContext.xml文件,
<!-- 自动扫描Bean --> <context:component-scan base-package="cn.szyxt"/> 这个没问题,那就是项目pom配置,没有加载Java文件夹,在相应的项目pom下,加上下面的这些配置,应该就可以找到Java文件的xml资源了。
下面贴出配置,和遇到的错误信息。
pom 配置:
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> </build>
错误信息:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'warnRecordsRptService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'warnRecordsRptDAOExtend': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [sqlMapConfig.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: java.io.IOException: Could not find resource cn/sqlmap/sms_server_config_SqlMap.xml
。。。中间错误信息。。。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'warnRecordsRptDAOExtend': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [sqlMapConfig.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: java.io.IOException: Could not find resource cn/sqlmap/sms_server_config_SqlMap.xml