Exception sending context spring mvc + hibernate4

J2EE 码拜 9年前 (2015-04-03) 1316次浏览 0个评论

1先贴报错

严重: 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 ""adminController"": Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tiantian.lexu.admin.logic.AdminLogic com.tiantian.lexu.admin.controller.AdminController.adminLogic; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tiantian.lexu.admin.logic.AdminLogic] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=adminLogic)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tiantian.lexu.admin.logic.AdminLogic com.tiantian.lexu.admin.controller.AdminController.adminLogic; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tiantian.lexu.admin.logic.AdminLogic] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=adminLogic)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
	... 37 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tiantian.lexu.admin.logic.AdminLogic] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=adminLogic)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:967)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:837)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:749)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
	... 39 more
2015-1-15 11:41:02 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2015-1-15 11:41:02 org.apache.catalina.core.StandardContext start
严重: Context [/appEval] startup failed due to previous errors
2015-1-15 11:41:02 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2015-1-15 11:41:02 org.apache.catalina.core.ApplicationContext log
信息: Shutting down log4j
2015-1-15 11:41:02 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/appEval] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@19724852]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2015-1-15 11:41:02 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2015-1-15 11:41:02 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2015-1-15 11:41:03 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2015-1-15 11:41:03 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2015-1-15 11:41:03 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2015-1-15 11:41:03 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2015-1-15 11:41:03 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2015-1-15 11:41:03 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/14  config=null
2015-1-15 11:41:03 org.apache.catalina.startup.Catalina start
2.再贴hibernate配置文件
[code=java]
  <!-- 加载common-config.properties文件 -->
     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
          <property name="location" value="classpath:config/common-config.properties" />
     </bean> 
     

    <!– 配置数据源 –>  
    <bean id=”dataSource”  
        class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>  
        <property name=”driverClassName” value=”com.mysql.jdbc.Driver” />  
        <property name=”url” value=”jdbc:mysql://127.0.0.1/appeval” />  
        <property name=”username” value=”root” />  
        <property name=”password” value=”root” />  
    </bean>  
    
    <!– 配置jdbc –>
    <bean id=”jdbcTemplate” class=”org.springframework.jdbc.core.JdbcTemplate”>
    <property name=”dataSource” ref=”dataSource”/>
    </bean>
  
  
    <!–  配置hibernate SessionFactory–>  
    <bean id=”sessionFactory”  
        class=”org.springframework.orm.hibernate4.LocalSessionFactoryBean”>  
        <property name=”dataSource” ref=”dataSource” />  
        <property name=”hibernateProperties”>  
            <props>  
                <prop key=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</prop>  
                <prop key=”hibernate.hbm2ddl.auto”>update</prop>  
                <prop key=”hibernate.show_sql”>true</prop>  
                <prop key=”hiberante.format_sql”>true</prop>  
            </props>  
        </property>  
        <property name=”configLocations”>  
            <list>  
                <value>  
                    classpath*:config/hibernate/hibernate.cfg.xml  
                </value>  
            </list>  
        </property>  
    </bean>  
[/code]

Exception sending context spring mvc + hibernate4
30分
com.tiantian.lexu.admin.logic.AdminLogic
这个bean有问题。
Exception sending context spring mvc + hibernate4
20分
要么显式定义一个bean id为adminLogic的,要么在com.tiantian.lexu.admin.logic.AdminLogic这个类的头部加上注解
Exception sending context spring mvc + hibernate4
15分
把实体bean贴出来,应该是标注加 的不对

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Exception sending context spring mvc + hibernate4
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!