zoukankan      html  css  js  c++  java
  • Spring的xml配置文件中约束的必要性 找不到元素 'beans' 的声明

    今天在复习Spring MVC框架的时候,只知道xml配置文件中的约束有规范书写格式的作用,所以在配置HandlerMapping对象信息的时候没有加入约束信息之后进行测试,没有遇到问题。后来在配置Spring的IOC容器的时候,配置好bean节点之后,没有添加约束,结果系统一直报“找不到元素 'beans' 的声明”这个错误。后来才发现,在applicationContext.xml中,约束不仅仅有规范书写格式的作用。详情如下,

    参考自:https://blog.csdn.net/xiaozhegaa/article/details/70198273

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        //上面两个是基础IOC的约束,必备
        xmlns:context="http://www.springframework.org/schema/context"
        //上面一个是开启注解管理Bean对象的约束
        xmlns:aop="http://www.springframework.org/schema/aop"
        //aop的注解约束
        xmlns:tx="http://www.springframework.org/schema/tx"
        //事务的约束
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd
        //上面两个是基础IOC的约束,必备
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        //上面一个是开启注解管理Bean对象的约束
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        //aop的注解约束
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">
        //事务的约束
    </beans>
    
  • 相关阅读:
    C++---拷贝构造函数和赋值构造函数
    C++---类成员变量定义为引用
    从文件处理到文件的高级应用
    Jupyter的使用复习
    字符编码到python编辑器流程
    周四的小结
    中秋前的题目
    三段代码块带走今天的脚本
    今日份的随笔
    明天才能学的运算符号表格
  • 原文地址:https://www.cnblogs.com/Zhanghaonihao/p/10475015.html
Copyright © 2011-2022 走看看