org.springframework.beans.factory.UnsatisfiedDependencyException

问题描述

今天自己弄了一下s2sh整合,抛出了异常! 这是applicationContext.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:p="http://www.springframework.org/schema/p"    xmlns:jee="http://www.springframework.org/schema/jee" 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/tx           http://www.springframework.org/schema/tx/spring-tx-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/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd           "    default-autowire="byType">    <context:annotation-config />    <context:component-scan base-package="*" />    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">        </property>        <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl">        </property>        <property name="username" value="liuwei"></property>        <property name="password" value="liuwei"></property>    </bean>    <bean id="sessionFactory"        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"        destroy-method="close">        <property name="dataSource">            <ref bean="dataSource" />        </property>        <property name="hibernateProperties">            <props>                <prop key="hibernate.dialect">                    org.hibernate.dialect.Oracle9Dialect                </prop>                <prop key="hibernate.show_sql"> true</prop>            </props>        </property>    </bean></beans> 这是web.xml<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">    <welcome-file-list>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list>    <filter>        <filter-name>struts2</filter-name>        <filter-class>            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>    <context-param>        <param-name>contextConfigLocation</param-name>        <param-value>            /WEB-INF/applicationContext.xml        </param-value>    </context-param>    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener></web-app> 这是包   问题补充:这个是错误信息<br /><br />严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener<br />org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDaoImpl' defined in file [E:Tomcat 6.0webappsliuweisshWEB-INFclassesliuweidaoimplUserDaoImpl.class]: Unsatisfied dependency expressed through bean property 'sessionFactory': : Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Cannot cache an unknown entity: java.runtime.name; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Cannot cache an unknown entity: java.runtime.name<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1150)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1040)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)<br />at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)<br />at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)<br />at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)<br />at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)<br />at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)<br />at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)<br />at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)<br />at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)<br />at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)<br />at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)<br />at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)<br />at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)<br />at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)<br />at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)<br />at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)<br />at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)<br />at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)<br />at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)<br />at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)<br />at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)<br />at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)<br />at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)<br />at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)<br />at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)<br />at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)<br />at org.apache.catalina.core.StandardService.start(StandardService.java:516)<br />at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)<br />at org.apache.catalina.startup.Catalina.start(Catalina.java:566)<br />at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />at java.lang.reflect.Method.invoke(Method.java:597)<br />at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)<br />at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)<br />Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Cannot cache an unknown entity: java.runtime.name<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)<br />at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)<br />at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)<br />at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)<br />at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)<br />at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:825)<br />at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:767)<br />at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:685)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1134)<br />... 37 more<br />Caused by: org.hibernate.MappingException: Cannot cache an unknown entity: java.runtime.name<br />at org.hibernate.cfg.Configuration.setCacheConcurrencyStrategy(Configuration.java:2065)<br />at org.hibernate.cfg.Configuration.setCacheConcurrencyStrategy(Configuration.java:2058)<br />at org.hibernate.cfg.Configuration.setCacheConcurrencyStrategy(Configuration.java:2052)<br />at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:729)<br />at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)<br />at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)<br />... 47 more<br />2011-9-15 9:41:09 org.apache.catalina.core.StandardContext start<br />严重: Error listenerStart<br />2011-9-15 9:41:09 org.apache.catalina.core.StandardContext start<br />严重: Context [/liuweissh] startup failed due to previous errors<br /><br /><br /><br />

解决方案

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingLocations"> <list> <value>classpath:/hibernate_mappings/*</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> </props> </property> </bean>你的持久化实体配置文件地址都没有配置
解决方案二:
...错误信息全部贴出来。

时间: 2024-09-13 02:44:13

org.springframework.beans.factory.UnsatisfiedDependencyException的相关文章

Spring Boot 调用 MongoRepository时报org.springframework.beans.factory.NoSuchBeanDefinitionException错误的解决办法

这个问题整整折腾了我两天,现在记录下来,希望可以帮助和我一样,遇到相同问题的小伙伴. 项目是分层的(Intellij IDEA中的模块Module),有API(Core)层,Service&Dao,Common,Model,上一张项目结构图.(不要在意为什么Service和Dao放在一起.这不是重点.) API中包括了Controller,Mongodb在Service&Dao层中,也就是API层,调用Service&Dao层,我敢用性命担保,所有注释,逻辑,都没有错,但是运行Sp

跪求大神帮解决org.springframework.beans.factory.BeanCreationException: Error creating b

问题描述 org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0':Initializationofbeanfailed;nestedexceptionisorg.springframework.beans.factory.Be

Spring-Bean的初始化(init方法和实现org.springframework.beans.factory.InitializingBean接口)

init()方法 在BEAN中增加一个方法inti(),用来完成初始化工作(去掉构造函数) 然后修改配置文档config.xml,指定Bean中要初始化的方法, 最后编写测试程序 Bean package com.gc.action; import java.util.Date; public class HelloWorld { private String msg=null;//该变量用来存储字符串 private Date date=null;//该变量用来存储日期 // public H

nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException

You should autowire interface AbstractManager instead of class MailManager. If you have different implemetations of AbstractManager you can write @Component("mailService") and then @Autowired @Qualifier("mailService") combination to au

javase-关于Myeclipse的错误org.springframework.beans.factory.BeanCreationException

问题描述 关于Myeclipse的错误org.springframework.beans.factory.BeanCreationException 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreati

ibatis和Spring整合抛org.springframework.beans.factory.BeanCreationException

问题描述 『spring2.5和Ibatis2整合』spring配置文件如下:<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://

求解决org.springframework.beans.factory.BeanCreationException

问题描述 dwr和spring整合时出的问题,请问有谁知道这是怎么回事呢? 具体代码如下: dwr.xml <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">

org.springframework.beans.factory.xml.XmlReaderContext.getReader()

问题描述 这个问题怎么解决咯,大侠们...500ServletExceptionjava.lang.NoSuchMethodError:org.springframework.beans.factory.xml.XmlReaderContext.getReader()Lorg/springframework/beans/factory/xml/XmlBeanDefinitionReader;atorg.apache.xbean.spring.context.v2c.XBeanQNameHelpe

spring hibernate-org.springframework.beans.factory.BeanCreationException

问题描述 org.springframework.beans.factory.BeanCreationException applicationContext.xml文件 <?xml version=""1.0"" encoding=""UTF-8""?> xmlns=""http://www.springframework.org/schema/beans"" xmlns: