cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'context:property-placeholder'找到声明

Rad*_*hna 17 spring

任何人都可以帮助我解决以下错误,因为我刚开始春天?

cvc-complex-type.2.4.c: The matching wildcard is strict, but no         
declaration can be found for element 'context:property-placeholder'.
Run Code Online (Sandbox Code Playgroud)

我在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"/>
Run Code Online (Sandbox Code Playgroud)

Jas*_*ues 33

Spring提供了许多额外的名称空间,提供了简单的方法来做事 - 比如tx(transactions),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>
Run Code Online (Sandbox Code Playgroud)

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