首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >spring 3-上下文:属性-占位符不绑定

spring 3-上下文:属性-占位符不绑定
EN

Stack Overflow用户
提问于 2011-11-02 17:40:54
回答 2查看 15.4K关注 0票数 4

我正在使用Spring3.0.5并试图通过上下文元素读取配置文件:

代码语言:javascript
运行
复制
<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-占位符没有绑定。

我做错了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-11-02 17:57:18

您还没有定义“上下文”是什么。

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

票数 23
EN

Stack Overflow用户

发布于 2019-04-28 15:35:19

更改applicationContext.xml中的bean配置

代码语言:javascript
运行
复制
<?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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7984848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档