Spring cvc complex type.2.4.c:匹配的通配符是严格的,但是找不到元素';上下文:属性占位符';

Spring cvc complex type.2.4.c:匹配的通配符是严格的,但是找不到元素';上下文:属性占位符';,spring,Spring,谁能帮我解决以下错误,因为我是新来的春天 cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:property-placeholder'. 我在applicationContext.xml中有以下配置: <beans xmlns="http://www.springframework.org/schema

谁能帮我解决以下错误,因为我是新来的春天

cvc-complex-type.2.4.c: The matching wildcard is strict, but no         
declaration can be found for element 'context:property-placeholder'.
我在applicationContext.xml中有以下配置:

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans       
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
xmlns:context="http://www.springframework.org/schema/context">

<bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<context:property-placeholder location="src/jdbc.properties"/>

Spring提供了一系列额外的名称空间,这些空间提供了简单的操作方法,如tx(事务)、util(utils)、mvc(Spring mvc声明):

要使用它,您必须在XML文件中设置模式映射。如果这样做了,您将获得基本的代码完成(您的IDE可能会提供更多)

声明上下文中的未设置/映射。

将您的声明更改为以下内容:

<?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>


如果愿意,还可以为内部组件设置自己的名称空间

如果使用Spring>=3.1,请使用PropertySourcesPlaceholderConfigurer,而不是旧的

解决方法: 替换


`


类路径:sport.properties

`

你好,贾斯珀。我有一个类似的XML问题。你能帮帮我吗?问题是-谢谢。嗨@BoratSagdiyev,很抱歉,我最近没有和Spring一起工作。我之所以能够回答上述问题,是因为它与“弹簧芯”有关。我相信有人能帮上忙。欢迎来到Stack Overflow!请不要把你的源代码扔在这里。对你的答案要和蔼可亲,尽量给它一个很好的描述,这样其他人就会喜欢它并投赞成票。见:
<context:property-placeholder location="classpath:sport.properties"/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:sport.properties</value>
</property>
</bean>