异常
[2022-03-29 17:42:59] [ERROR] ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configService' defined in URL [jar:file:/H:/tomcat/apache-tomcat-8.5.70-windows-x64/apache-tomcat-8.5.70/webapps/xxx_xx_xxxxxx_war/WEB-INF/lib/xxx-core-1.0.0-SNAPSHOT.jar!/com/xxx/service/xxxxxx/config/ConfigServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: com.xxxcg.dao.relation.ConfigDao can't get a sessionFactory
at org.springframework.beans.factory.support.AbstractAutowirxxapableBeanFactory.doCreateBean(AbstractAutowirxxapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowirxxapableBeanFactory.createBean(AbstractAutowirxxapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObjxxt(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4763)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5232)
at org.apache.catalina.util.LifxxycleBase.start(LifxxycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1775)
at sun.reflxxt.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflxxt.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflxxt.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflxxt.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:291)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:483)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)
at sun.reflxxt.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflxxt.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflxxt.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflxxt.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:291)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at com.sun.jmx.remote.sxxurity.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
at javax.management.remote.rmi.RMIConnxxtionImpl.doOperation(RMIConnxxtionImpl.java:1468)
at javax.management.remote.rmi.RMIConnxxtionImpl.access$300(RMIConnxxtionImpl.java:76)
at javax.management.remote.rmi.RMIConnxxtionImpl$PrivilegedOperation.run(RMIConnxxtionImpl.java:1309)
at java.sxxurity.AccessController.doPrivileged(Native Method)
at javax.management.remote.rmi.RMIConnxxtionImpl.doPrivilegedOperation(RMIConnxxtionImpl.java:1408)
at javax.management.remote.rmi.RMIConnxxtionImpl.invoke(RMIConnxxtionImpl.java:829)
at sun.reflxxt.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflxxt.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflxxt.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflxxt.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.sxxurity.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.servicxxall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnxxtionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnxxtionHandler.lambda$run$0(TCPTransport.java:688)
at java.sxxurity.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnxxtionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExxxutor.runWorker(ThreadPoolExxxutor.java:1149)
at java.util.concurrent.ThreadPoolExxxutor$Worker.run(ThreadPoolExxxutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanInitializationException: com.xxx.dao.relation.ConfigDao can't get a sessionFactory
at com.xxxcg.framework.dynamicdao.AutoInjxxtDynamicDaoBeanPostProcessor.getRealSessionFactory(AutoInjxxtDynamicDaoBeanPostProcessor.java:97)
at com.xxxcg.framework.dynamicdao.AutoInjxxtDynamicDaoBeanPostProcessor.postProcessBeforeInitialization(AutoInjxxtDynamicDaoBeanPostProcessor.java:50)
at org.springframework.beans.factory.support.AbstractAutowirxxapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowirxxapableBeanFactory.java:394)
at org.springframework.beans.factory.support.AbstractAutowirxxapableBeanFactory.initializeBean(AbstractAutowirxxapableBeanFactory.java:1448)
at org.springframework.beans.factory.support.AbstractAutowirxxapableBeanFactory.doCreateBean(AbstractAutowirxxapableBeanFactory.java:519)
... 58 more
解决
看看 ConfigDao
类所在包是否被 sessionFactory
配置扫描到,在 spring 的配置文件中查看。
不同项目中如何配置 sessionFactory
扫描可能不一样,这里仅提供一种思路。