今天在复习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>

Spring的xml配置文件中约束的必要性 找不到元素 'beans' 的声明的更多相关文章

  1. 系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常

    现象:spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException; lineNumb ...

  2. SSH问题:系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常

    现象:spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException; lineNumb ...

  3. Spring的配置文件找不到元素 'beans' 的声明

    Spring的配置文件找不到元素 'beans' 的声明 一般是由Spring的版本导致的,你可以尝试使用如下的某一种. <?xml version="1.0" encodi ...

  4. SSM——[/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; cvc-elt.1: 找不到元素 'beans' 的声明。

    报错文件:/SSM_Integration/WebContent/WEB-INF/applicationContext.xml <beans xmlns="http://www.spr ...

  5. 关于spring项目报错:找不到元素 'beans' 的声明的解决办法

    @参考文章 首先是spring.xml中引用地址错误,部分http://***写成https://***了. 其次是spring.xml中引入的版本不对,我用的4.1.3的,直接写 http://ww ...

  6. Spring 在 xml配置文件 或 annotation 注解中 运用Spring EL表达式

    Spring  EL 一:在Spring xml 配置文件中运用   Spring EL Spring EL 采用 #{Sp Expression  Language} 即 #{spring表达式} ...

  7. Spring框架xml配置文件 复杂类型属性注入——数组 list map properties DI dependency injection 依赖注入——属性值的注入依赖于建立的对象(堆空间)

    Person类中的各种属性写法如下: package com.swift.person; import java.util.Arrays; import java.util.List; import ...

  8. commons-logging 和log4j包下载 Spring根据XML配置文件生成对象

    需要用到Spring压缩包中的四个核心JAR包 beans .context.core 和expression 下载地址: https://pan.baidu.com/s/1qXLHzAW 以及日志j ...

  9. Spring 通过XML配置文件以及通过注解形式来AOP 来实现前置,环绕,异常通知,返回后通知,后通知

    本节主要内容: 一.Spring 通过XML配置文件形式来AOP 来实现前置,环绕,异常通知     1. Spring AOP  前置通知 XML配置使用案例     2. Spring AOP   ...

随机推荐

  1. 【转载】 github vue 高星项目

    内容 UI组件 开发框架 实用库 服务端 辅助工具 应用实例 Demo示例 UI组件 element ★13489 - 饿了么出品的Vue2的web UI工具套件 Vux ★8133 - 基于Vue和 ...

  2. JavaScript数组方法--reduce、reduceRIght、reverse

    今天写的reduce是比较复杂的一个数组方法,其实在这之前我也用过reduce,可是每次用起来总感觉不那么顺手,主要还是因为不熟,对reduce本身不熟.首先reduce这个单词翻译为中文,不那么直观 ...

  3. DLC 数制与数制的转换

    进位计数值:用进位的方法进行计数 常用数值有十进制.二进制.八进制.十六进制等. 进位计数制把包括基数与权两个基本问题.

  4. Android 开发 重写定位器类Timer与TimerTask

    class AttendanceTimer extends Timer { private static final int LOCATION = 0x01; private static final ...

  5. The component and implementation of a basic gradient descent in python

    in my impression, the gradient descent is for finding the independent variable that can get the mini ...

  6. 【perl】simpleHTTP

    类似Python SimpleHTTPServer #!/usr/bin/perl # https://metacpan.org/pod/HTTP::Server::Simple # https:// ...

  7. 稀疏矩阵 part 4

    ▶ 各种稀疏矩阵数据结构下 y(n,1) = A(n,m) * x(m,1) 的实现,GPU版本 ● MAT 乘法 __global__ void dotGPU(const MAT *a, const ...

  8. Flask框架里的cookie和session

    # -*- encoding: utf-8 -*- #cookie 相关的操作,依赖与make_response库,调用cookie依赖request模块 from flask import Flas ...

  9. 使用shell命令给文件中每一行的前面、后面添加字符

    shell command shell给一个文件中的每一行开头插入字符的方法:awk '{print "xxx"$0}' fileName shell给一个文件中的每一行结尾插入字 ...

  10. bashrc和bash_profile

    在~/.bashrc中起别名 !/bin/bash下必须加上shopt -s expand_aliases #!/bin/sh下不用 shopt -s expand_aliases 这一条命令让she ...