当前位置: 代码迷 >> Java Web开发 >> Spring org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:解决思路
  详细解决方案

Spring org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:解决思路

热度:325   发布时间:2016-04-17 10:16:30.0
Spring org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
配置如下
测试环境老是抱如下错误:Line 17 in XML document from class path resource [beans.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 found for element 'context:component-scan'.
不知道为什么?
求指点,在线等啊.......

<?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"
  xmlns:aop="http://www.springframework.org/schema/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-3.0.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  http://www.springframework.org/schema/aop 
  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
  

   
  <context:component-scan base-package="cn.edu.nupt.bean.product"/>
  <context:property-placeholder location="classpath:jdbc.properties"/>
  
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
  <property name="driverClassName" value="${driverClassName}" />
  <property name="url" value="${url}" />
  <property name="userName" value="${userName}" />
  <property name="password" value="${password}" />
  <property name="initialSize" value="${initialSize}" />
  <property name="maxActive" value="${maxActive}" />
  <!-- collaborators and configuration for this bean go here -->
  </bean>

  <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="dataSource" ref="dataSource"/>
  <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
  <property name="loadTimeWeaver">
  <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
  </property>
  </bean>

  <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  <property name="entityManagerFactory" ref="entityManagerFactory"/>
  </bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

------解决方案--------------------
楼主请查看下<context:component-scan base-package="cn.edu.nupt.bean.product"/>设置的包名是否存在。
------解决方案--------------------
你的配置文件声明是不是缺少context。


XML code
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/[color=#FF0000]context[/color]" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat Jun 23 05:00:24 CST 2018
  • 最近登录:Sat Jun 23 05:00:24 CST 2018
  • 最近登录:Sat Jun 23 05:00:24 CST 2018
  • 最近登录:Sat Jun 23 05:00:24 CST 2018
  • 最近登录:Sat Jun 23 05:00:24 CST 2018