trying to integrate hibernate and spring ,I ran into this error
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanC
Or you can mention <mvc:annotation-driven/>
in your XML and remove the
<context:component-scan base-package="org.me.spring.hib.school.web" />
part.
If you are comfortable with XML notations.
I faced similar kind of problem. I have defined the controller class with "@Controller" and also in the Spring-config.xml file as a bean and have injected the dependencies.
This was causing the problem. @Controller is defining the bean and again, the bean defined in the xml file is redefining the dependencies. I tried autowiring the dependency and removed it as a bean from the xml file. Then it worked.
This is happening because you have both
<context:component-scan base-package="org.me.spring.hib.school.web" />
and
<bean class="org.me.spring.hib.school.web.SchoolController" >
The first line will auto-discover and register a SchoolController
for you. By explicitly declaring another one, you get a duplicate, and the url-mapping will clash.
You need to either remove the <context:component-scan>
, or remove the explicit bean definitions for the controller and the DAO. If you do the latter, then you'll need to use autowiring to inject their dependencies.