我正在使用Spring3.0.5并试图通过上下文元素读取配置文件:
<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"/>当应用程序启动时,我得到以下错误:
违规资源: ServletContext资源/WEB/ ServletContext /applicationContext.xml;嵌套异常是ServletContext资源/WEB/spring/db-config.xml文档中的ServletContext第20行无效;嵌套异常是org.xml.sax.SAXParseException:元素的前缀"context“:property-占位符没有绑定。
我做错了什么?
发布于 2011-11-02 17:57:18
您还没有定义“上下文”是什么。
您需要添加xmlns:context="http://www.springframework.org/schema/context"
发布于 2019-04-28 15:35:19
更改applicationContext.xml中的bean配置
<?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-3.0.xsd">
</beans>https://stackoverflow.com/questions/7984848
复制相似问题