1
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans    http://www.springframework.org/schema/beans/spring-beans.xsd"
    xmlns:context="http://www.springframework.org/schema/context">

   <context:annotation-config/>


<context:component-scan base-package="org.dao.impl"/>

<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">  
    <property name="driverClassName" value="${db.driver}"/>
    <property name="url" value="${db.jdbcurl}; create=true"/>
    <property name="username" value="${db.username}"/>
    <property name="password" value="${db.password}"/>
    <property name="initialSize" value="3"/>
</bean>

Below is the error I am getting.

Sep 11, 2014 12:03:45 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1d33a6b: startup date [Thu Sep 11 12:03:45 EDT 2014]; root of context hierarchy
Sep 11, 2014 12:03:45 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring.xml]
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 7 in XML document from class path resource [spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)

I am also getting "The fully qualified name of the bean's class, except if it serves only as a parent definition for child bean definitions." when I hover my mouse over class="org.apache.commons.dbcp.BasicDataSource" What does it mean?

Could someone help me resolve the issue. I am trying to work on a simple spring hibernate and mysql. Thanks.

1

3 Answers 3

3

Also adding this dependency to pom.xml worked for me :)

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
Sign up to request clarification or add additional context in comments.

Comments

2

I think your error is more related to the fact that you are using an XML namespace without declaring it.

As explainted in this answer. Try to add http://www.springframework.org/schema/context/spring-context.xsd to the schemaLocation:

<?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.xsd">

2 Comments

Or use the version less variant. So spring uses the highest version od the xsd file that is found in classpath.
Thanks @XavierDelamotte. What if Im using spring framework 4.0?
-1

Add buildPath commons-dpcp2.jar, if it is not available with you please follow this link.

Download and add your Build Path of your Eclipse.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.