Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener 
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'departmentDao' defined in class path resource [spring/applicationContext-department.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'hibernateTemplate' of bean class [cn.baixun.oa.dao.iml.DepartmentDaoIml]: No property 'hibernateTemplate' found 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480) 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) 
 at java.security.AccessController.doPrivileged(Native Method) 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) 
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) 
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) 
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) 
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) 
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) 
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) 
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) 
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) 
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) 
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) 
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) 
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797) 
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291) 
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) 
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114) 
 at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673) 
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
 at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
 at java.lang.Thread.run(Thread.java:744) 
 Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'hibernateTemplate' of bean class [cn.baixun.oa.dao.iml.DepartmentDaoIml]: No property 'hibernateTemplate' found 
 at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:382) 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1288) 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1249) 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) 
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) 
 ... 27 more 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.core.StandardContext startInternal 
 严重: Error listenerStart 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.core.StandardContext startInternal 
 严重: Context [/OA] startup failed due to previous errors 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.core.ApplicationContext log 
 信息: Closing Spring root WebApplicationContext 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 
 严重: The web application [/OA] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
 严重: The web application [/OA] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.startup.HostConfig deployDirectory 
 信息: Deploying web application directory D:\developer\developer software\apache-tomcat-7.0.35-windows64\apache-tomcat-7.0.35\webapps\ROOT 
 五月 03, 2014 6:42:07 下午 org.apache.coyote.AbstractProtocol start 
 信息: Starting ProtocolHandler ["http-apr-8080"] 
 五月 03, 2014 6:42:07 下午 org.apache.coyote.AbstractProtocol start 
 信息: Starting ProtocolHandler ["ajp-apr-8009"] 
 五月 03, 2014 6:42:07 下午 org.apache.catalina.startup.Catalina start 
 信息: Server startup in 5869 ms 
 
以下是spring 的配置
application.xml
 <?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:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                            http://www.springframework.org/schema/aop 
                            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                            http://www.springframework.org/schema/context 
                            http://www.springframework.org/schema/context/spring-context-2.5.xsd
                            http://www.springframework.org/schema/tx 
                            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
        <import resource="applicationContext-db.xml"/>
        <import resource="applicationContext-person.xml"/>
        <import resource="applicationContext-department.xml"/>
        
 </beans>
 application-department.xml 
 <?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:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                            http://www.springframework.org/schema/aop 
                            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                            http://www.springframework.org/schema/context 
                            http://www.springframework.org/schema/context/spring-context-2.5.xsd
                            http://www.springframework.org/schema/tx 
                            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     <!-- 
     其中的一种解决方案
      -->
    
  
    
  <bean id="departmentDao" class="cn.baixun.oa.dao.iml.DepartmentDaoIml">
  <property name="hibernateTemplate">
  <ref bean="hibernateTemplate"/>
  </property>
  </bean>
      
      
     <bean id="departmentService" class="cn.baixun.oa.service.iml.DepartmentServiceIml">
     <property name="departmentDao">
     <ref bean="departmentDao"/>
     </property>
     </bean>
     
     <bean id="departmentAction" class="cn.baixun.oa.struts2.action.DepartmentAction" scope="prototype">
     <property name="departmentService">
     <ref  bean="departmentService"/>
     </property>
     </bean>
 </beans>
 
 
 
以下是注入hibernateTemplate的地方
BaseDaoIml.java
 package cn.baixun.oa.dao.base.iml;
 
 import java.io.Serializable;
 import java.lang.reflect.ParameterizedType;
 import java.util.Collection;
 
 
 import javax.annotation.Resource;
 
 
 import org.springframework.orm.hibernate3.HibernateTemplate;
 import org.springframework.stereotype.Repository;
 
 
 import cn.baixun.oa.dao.base.BaseDao;
 
 
 public class BaseDaoIml<T> implements BaseDao<T>{
     private Class classType;
 public BaseDaoIml(){
 ParameterizedType type=(ParameterizedType) this.getClass().getGenericSuperclass();
 classType=(Class) type.getActualTypeArguments()[0];
 }
 @Resource(name="hibernateTemplate")
 public HibernateTemplate hibernateTemplate;
 public void saveEntry(T t) {
 this.hibernateTemplate.save(t);
 
 }
 
 
 @Override
 public void updateEntry(T t) {
 this.hibernateTemplate.update(t);
 
 }
 
 
 @Override
 public void deleteEntry(Serializable id) {
 T t=this.getEntryById(id);
 this.hibernateTemplate.delete(t);
 
 }
 
 
 
 @Override
 public T getEntryById(Serializable id) {
 
 return (T) this.hibernateTemplate.get(classType, id);
 }
 
 
 @Override
 public Collection<T> getAllEntry() {
 
 return this.hibernateTemplate.find("from"+this.classType.getName());
 }
 
 
 } 
 package cn.baixun.oa.dao.iml;
 
 
 import javax.annotation.Resource;
 import javax.xml.ws.RespectBinding;
 
 
 import org.springframework.orm.hibernate3.HibernateTemplate;
 import org.springframework.stereotype.Repository;
 
 
 import cn.baixun.oa.dao.DepartmentDao;
 import cn.baixun.oa.dao.base.iml.BaseDaoIml;
 import cn.baixun.oa.domain.Department;
 @Repository("departmentDao")
 public class DepartmentDaoIml extends BaseDaoIml<Department> implements
 DepartmentDao<Department> {
 }
 
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。