关于在Spring配置特殊bean-分散配置的时候抛出的异常:无法找到元素 'context:component-scan' 的声明 的解决方法
2017-09-01 15:47
633 查看
方法很简单,就是beans的声明xmlns和xsi:schemaLocation的时没有把xmlns:context相对应的那些配置声明上去。
解决方法:只需要在<beans>里面声明上去即可。
代码如下:
这个是直接在<beans>里面粘贴上去即可
xmlns:context="http://www.springframework.org/schema/context"
然后这个则是在xsi:schemaLocation=" "里面粘贴进去
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
例:我的是这样子的:
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" >
需要注意的是
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
这两个要粘贴在一起,不要间插其他的语句也不要被其他语句间插,语句应该都是两句两句黏在一起的,就想这样
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
不知道你们的会不会这样,反正我的如果换成这样 ↓ 就会报错
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/context
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context/spring-context.xsd"
所以我觉得还是两两粘贴,不要分开比较好- -
仅为个人记事,大牛觉得有不对的地方,可以点出来帮我改正- -不喜勿喷喜请点赞。》》》》》》
解决方法:只需要在<beans>里面声明上去即可。
代码如下:
这个是直接在<beans>里面粘贴上去即可
xmlns:context="http://www.springframework.org/schema/context"
然后这个则是在xsi:schemaLocation=" "里面粘贴进去
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
例:我的是这样子的:
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" >
需要注意的是
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
这两个要粘贴在一起,不要间插其他的语句也不要被其他语句间插,语句应该都是两句两句黏在一起的,就想这样
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
不知道你们的会不会这样,反正我的如果换成这样 ↓ 就会报错
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/context
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context/spring-context.xsd"
所以我觉得还是两两粘贴,不要分开比较好- -
仅为个人记事,大牛觉得有不对的地方,可以点出来帮我改正- -不喜勿喷喜请点赞。》》》》》》
相关文章推荐
- 关于spring”通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明“的错误
- 关于spring”通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明“的错误
- 关于spring”通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明“的错误
- 关于spring”通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明“的错误
- SpringMVC 出现通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明。
- 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明
- 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明
- spring配置必须声明元素类型 "context:component-scan"。
- 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明。
- 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明。--问题的原因及解决方案
- spring 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明
- 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明。
- spring的xml中注册bean的时候报错1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>
- spring的xml中注册bean的时候报错1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>
- 关于使用注解的Spring配置文件的配置<context:annotation-config/>&&<context:component-scan base-package=”XX.XX”/>
- spring报错:通配符的匹配很全面, 但无法找到元素 'context:annotation-config' 的声明
- Asp.net 配置--关于无法找到该页的解决方法
- spring的xml中注册bean的时候报错1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>
- Spring配置报错:通配符的匹配很全面,但无法找到元素‘util:list’的声明
- Spring 配置文件报错:元素 "context:component-scan" 的前缀 "context" 未绑定。