使用Spring时遇到的bug及解决

时间:2023-03-10 00:03:57
使用Spring时遇到的bug及解决

1.myeclipse中Spring 不给提示

解决:(1)window – preferences – myeclipse – files and editors – xml – xml catalog

(2)  User Specified Entries – add

i.          Location:       D:\share\0900_Spring\soft\spring-framework-2.5.6\dist\resources\spring-beans-2.5.xsd

ii.         URI:             file:///D:/share/0900_Spring/soft/spring-framework-2.5.6/dist/resources/spring-beans-2.5.xsd

iii.        Key Type:      Schema Location

iv.        Key:              http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

2.在myeclipse中无法直接读API

解决:在spring.jar上右键—properties—javadoc Location,然后browse到api文件夹

3.xml文件必须要从第一行开始写,若空出第一行,从第二行写则会抛出异常:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from class path resource [beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。

4.   java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

解决:引入commons-logging.jar包