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>
Spring的xml配置文件中约束的必要性 找不到元素 'beans' 的声明的更多相关文章
- 系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常
现象:spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException; lineNumb ...
- SSH问题:系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常
现象:spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException; lineNumb ...
- Spring的配置文件找不到元素 'beans' 的声明
Spring的配置文件找不到元素 'beans' 的声明 一般是由Spring的版本导致的,你可以尝试使用如下的某一种. <?xml version="1.0" encodi ...
- 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 ...
- 关于spring项目报错:找不到元素 'beans' 的声明的解决办法
@参考文章 首先是spring.xml中引用地址错误,部分http://***写成https://***了. 其次是spring.xml中引入的版本不对,我用的4.1.3的,直接写 http://ww ...
- Spring 在 xml配置文件 或 annotation 注解中 运用Spring EL表达式
Spring EL 一:在Spring xml 配置文件中运用 Spring EL Spring EL 采用 #{Sp Expression Language} 即 #{spring表达式} ...
- Spring框架xml配置文件 复杂类型属性注入——数组 list map properties DI dependency injection 依赖注入——属性值的注入依赖于建立的对象(堆空间)
Person类中的各种属性写法如下: package com.swift.person; import java.util.Arrays; import java.util.List; import ...
- commons-logging 和log4j包下载 Spring根据XML配置文件生成对象
需要用到Spring压缩包中的四个核心JAR包 beans .context.core 和expression 下载地址: https://pan.baidu.com/s/1qXLHzAW 以及日志j ...
- Spring 通过XML配置文件以及通过注解形式来AOP 来实现前置,环绕,异常通知,返回后通知,后通知
本节主要内容: 一.Spring 通过XML配置文件形式来AOP 来实现前置,环绕,异常通知 1. Spring AOP 前置通知 XML配置使用案例 2. Spring AOP ...
随机推荐
- memory_profiler的使用
作用:memory_profiler是用来分析每行代码的内存使用情况 使用方法一: 1.在函数前添加 @profile 2.运行方式: python -m memory_profiler memory ...
- IE高级配置中,存在SSL支持协议,例如SSL TLS。
IE高级配置中,存在SSL支持协议,例如SSL TLS. 其在注册表的路径为:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\I ...
- 关于ueditor插入不了动态地图
1. 打开编辑器根目录下面的ueditor.all.js文件,找到: table.setAttribute("data-sort", cmd == "enablesort ...
- 如何解决iOS界面操作导致导致NSTimer暂停计时的问题?
在NSTimer代码后面加上以下代码,这样滚动scroll的时候就不会暂停了.NSRunLoop *t = [NSRunLoop currentRunLoop];[t addTimer: timer ...
- ActiveMQ(4)---ActiveMQ原理分析之消息消费
消费端消费消息的原理 我们通过上一节课的讲解,知道有两种方法可以接收消息,一种是使用同步阻塞的MessageConsumer#receive方法.另一种是使用消息监听器MessageListener. ...
- HiveServer2的WEB UI界面
1.hive-site.xml配置如下: <property> <name>hive.server2.webui.host</name> <val ...
- ios端滚动优化
加入css -webkit-overflow-scrolling: touch;
- 如何创建数据库以及MySQL增删改查命令的简单运用
在已经安装好MySQL的前提下 1.在Windows打开命令提示符窗口,输入命令启动MySQL命令行工具并登入root用户:mysql -h localhost -u root -p 2.输入密码后, ...
- 魔力Python——一些基本概念
1.I/O操作 I/O输入/输出(input/output)的缩写. 概念I/O系统,英文全称为“Input output system”,中文全称为“输入输出系统”,由输入输出控制系统和外围设备两部 ...
- POC iis短文件名
__author__ = '*'# -*- coding:utf-8 -*- from lib.httpparse import httpparse def verify(protocol,ip,po ...