服务器启动时报Error creating bean with name 'sqlMapClient' defined in class .

服务器一启动就报如下的错误,当时依照错误提示很是不解:
1.Caused by: org.springframework.beans.factory.BeanCreationException:    
2.Could not autowire field: private com.huawei.support.dao.DaoManager com.huawei.support.attachment.dao.AttachmentDAO.mDaoManager;    
3.nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoManager':    
4.Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.   
5.BeanCreationException: Could not autowire method:   
6.public void com.huawei.support.dao.DaoManager.setSqlMap(com.ibatis.sqlmap.client.SqlMapClient);   
7.nested exception is org.springframework.beans.factory.   
8.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class  
9.path resource [applicationContext.xml]: Invocation of init method failed; nested exception is    
10.org.springframework.core.NestedIOException: Failed to parse config resource: class path resource    
11.[sql-map-config.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML.    
12.Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.   
13.Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.     
14.Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/select'.   
15.Cause: com.ibatis.sqlmap.client.SqlMapException: Error.  Could not initialize class.  Cause: java.lang.ClassNotFoundException: com.szelink.zfaq.alarm.aqyj.action.AlarmWycgBean at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507)   
16.    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)   
17.    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)   
18.    ... 37 more  



(1) 如上的错误提示,没有发现该类。但是在项目中确实存在所提到的类的。如是就想是不是我创建的applicationContext.xml配置文件中有问题。在该配置文件中创建bean有问题。
(2) 后来进一步的查找如下的错误提示引起了注意:
1.Cause: com.ibatis.sqlmap.client.SqlMapException: Error.   
2.Could not initialize class.     
3.Cause: java.lang.ClassNotFoundException:com.szelink.zfaq.alarm.aqyj.action.AlarmWycgBean 

此时怀疑是不是在Ibatis的配置文件中新加的SQL引进了错误。如是删掉了刚刚添加的SQL发现,服务器启动正常。如是定位出使新加的SQL引进的问题的。新加的SQL如下所示:
	<!-- 最新预警信息 -->
	<select id="newWarnings" resultClass="java.util.HashMap" parameterClass="com.szelink.zfaq.alarm.aqyj.action.AlarmWycgBean">
		 <include refid="ORACLE_PAGE_HEADER" />
			SELECT T.* ,G.ORG_NAME FROM ( 
		      SELECT UNITID,ALARMDATE,
		      SUM(CASE WHEN  CATEGORY = '1' THEN NUMS ELSE 0 END) ONE,
		      SUM(CASE WHEN  CATEGORY = '2' THEN NUMS ELSE 0 END) TWO,
		      SUM(CASE WHEN  CATEGORY = '3' THEN NUMS ELSE 0 END) THREE,
		      SUM(CASE WHEN  CATEGORY = '4' THEN NUMS ELSE 0 END) FOUR,
		      SUM(CASE WHEN  CATEGORY = '5' THEN NUMS ELSE 0 END) FIVE,
		      SUM(CASE WHEN  CATEGORY = '6' THEN NUMS ELSE 0 END) SIX,
		      SUM(CASE WHEN  CATEGORY = '7' THEN NUMS ELSE 0 END) SEVEN,
          	  SUM(CASE WHEN  CATEGORY = '99' THEN NUMS ELSE 0 END) OTHER,
		      SUM(NUMS) TOTAL
		       FROM(
			      SELECT R.UNITID , D.CATEGORY , R.ALARMDATE,SUM(D.NUMS) NUMS FROM T_ALARM_REVIEWS R
			       INNER JOIN T_ALARM_REVIEWS_DETAILS D ON R.TID = D.PTID
			       GROUP BY R.UNITID , D.CATEGORY , R.ALARMDATE
		       ) GROUP BY UNITID ,ALARMDATE
		       ) T INNER JOIN Z_RES_ORG  G ON T.UNITID = G.ORG_ID ORDER  BY  ALARMDATE DESC, TOTAL DESC
		  <include refid="ORACLE_PAGE_FOOTER" />  
	</select>

(3)最后经过分析发现 parameterClass="com.szelink.zfaq.alarm.aqyj.action.AlarmWycgBean" 在配置文件中并没有这样的一个别名,它是对应到一个类的。由于没有配置导致Server在解析配置文件时无法识别该类,而导致Cause: java.lang.ClassNotFoundException: com.szelink.zfaq.alarm.aqyj.action.AlarmWycgBean
(4)最终可以这样解决:在parameterClass中写入自己类对应的javabean

你可能感兴趣的:(client)