zoukankan      html  css  js  c++  java
  • Spring框架学习笔记——各种异常、报错解决

    一、部分标签无法使用

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

  • 相关阅读:
    [BZOJ 4710] 分特产
    洛谷 P4827 [国家集训队] Crash 的文明世界
    Test 7.12 T2
    [洛谷 P1377] TJOI2011 树的序
    [洛谷 P1013] NOIP1998 提高组 进制位
    ajax2
    Ajax
    javascript下兼容都有哪些
    获取类名 封装 getStyle
    作用域
  • 原文地址:https://www.cnblogs.com/huangjian2/p/6101051.html
Copyright © 2011-2022 走看看