Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:property-placeholder'

Tags:

spring

could anyone help me resolving the following error as i am new to spring?

cvc-complex-type.2.4.c: The matching wildcard is strict, but no         
declaration can be found for element 'context:property-placeholder'.

I have the following configuration in 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"/>
like image 602
Radhakrishna Avatar asked Jan 28 '13 07:01

Radhakrishna


2 Answers

Spring provides a bunch of additional name-spaces that provide short-hand ways to do things - things like tx (transactions), util (utils), mvc (spring MVC declarations):

To use one, you have to set up the schema mapping in your XML file. If this is done, you get basic code-completion (your IDE may provide more). .

In your declaration context was not set-up/mapped.

Change your declaration to the following:

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

You can also set up your own namespaces for in-house components, if you wish.

like image 128
Jasper Blues Avatar answered Sep 17 '22 10:09

Jasper Blues


If you use Spring >= 3.1, use PropertySourcesPlaceholderConfigurer rather than the old.

Workaround: Replace

<context:property-placeholder location="classpath:sport.properties"/>

BY

`

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:sport.properties</value>
</property>
</bean>

`

like image 37
Devayan Thakur Avatar answered Sep 19 '22 10:09

Devayan Thakur