一、部分标签无法使用
原因:没有util导入命名空间
解决方法:在bean配置文件头部引用命名空间
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
">
类似的导入context命名空间
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
二、nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'util:list'.
原因:命名空间导入不完整。只在头部写了xmlns:util="http://www.springframework.org/schema/util"
解决方法:正确导入命名空间
三、No constructor with 0 arguments defined in class 'com.broadtext.beans.Helloworld'
原因:缺少无参构造方法
解决方法:添加无参构造方法
四、BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
原因:ApplicationContext ctx = new ClassPathXmlApplicationContext();没有指定xml文件
解决方法:ApplicationContext ctx = new ClassPathXmlApplicationContext("beans-XXX.xml");