码迷,mamicode.com
首页 > 编程语言 > 详细

服务器加载spring配置文件报context:component-scan节点未声明解决方法

时间:2015-08-01 15:29:17      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

关于jboss服务器启动,spring配置文件加载报错解决方法

The matching wildcard is strict, but no declaration can be found for element ‘context:component-scan‘.

spring配置文件代码:

    <!-- 自动扫描的包名 -->
    <context:component-scan base-package="com.regaltec.gtfhr.*,cn.tisson.*" ></context:component-scan>
    <context:component-scan base-package="cn.tisson.train.*" ></context:component-scan>

日志文件:

12:26:45,015 INFO  [STDOUT] 2015-08-01 12:26:45 INFO  org.springframework.web.co
ntext.support.XmlWebApplicationContext  Refreshing org.springframework.web.conte
xt.support.XmlWebApplicationContext@186b0ee: display name [Root WebApplicationCo
ntext]; startup date [Sat Aug 01 12:26:45 CST 2015]; root of context hierarchy
12:26:45,078 INFO  [STDOUT] 2015-08-01 12:26:45 INFO  org.springframework.beans.
factory.xml.XmlBeanDefinitionReader  Loading XML bean definitions from class pat
h resource [com/regaltec/common/config/applicationContext.xml]
12:26:45,140 INFO  [STDOUT] 2015-08-01 12:26:45 ERROR org.springframework.web.co
ntext.ContextLoader  Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 452
in XML document from class path resource [com/regaltec/common/config/application
Context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-
complex-type.2.4.c: The matching wildcard is strict, but no declaration can be f
ound for element context:component-scan.

出现这错误因为在applicationContext.xml文件中的配置beans节点的xsi:schemaLocation属性值漏了

http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd

例子项目完整的beans节点属性配置如下:

<?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:jee="http://www.springframework.org/schema/jee"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
        

 

服务器加载spring配置文件报context:component-scan节点未声明解决方法

标签:

原文地址:http://www.cnblogs.com/liongzai/p/4694119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!