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>
    
  • 相关阅读:
    UDP最大传输字节
    [bzoj3994] [SDOI2015]约数个数和
    [bzoj3529] [Sdoi2014]数表
    [bzoj3309] DZY Loves Math
    [bzoj2693] jzptab
    [bzoj4407] 于神之怒加强版
    [bzoj3688] 折线统计
    [bzoj2301] [HAOI2011]Problem b
    [bzoj2820] YY的GCD
    [bzoj4559] [JLoi2016]成绩比较
  • 原文地址:https://www.cnblogs.com/Zhanghaonihao/p/10475015.html
Copyright © 2011-2022 走看看