2011-11-02 36 views
1

我與春天3.0.5工作,並試圖通過閱讀上下文元素的配置文件:Spring MVC的3-背景:物業佔位符不綁定

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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:property-placeholder location="classpath:db_config.properties"/> 

當應用程序啓動時,我得到以下錯誤:

Offending resource: ServletContext resource [/WEB-INF/spring/applicationContext.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 20 in XML document from ServletContext resource [/WEB-INF/spring/db-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "context" for element "context:property-placeholder" is not bound.

我在做什麼錯了?

回答

16

您尚未定義「上下文」是什麼。

您需要添加xmlns:context="http://www.springframework.org/schema/context"