码迷,mamicode.com
首页 > 编程语言 > 详细

Spring框架学习笔记——各种异常、报错解决

时间:2016-12-02 11:53:41      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:添加   3.1   hello   www   ict   log   lex   already   oca   

一、部分标签无法使用

技术分享

原因:没有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");

Spring框架学习笔记——各种异常、报错解决

标签:添加   3.1   hello   www   ict   log   lex   already   oca   

原文地址:http://www.cnblogs.com/huangjian2/p/6101051.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!