UserDAOSupport.xml
<beans ...................

   <import resource="spring_unite_hibernate/FactoryConfigDataSource.xml"/>
   <bean id="UserDao" class="spring_unite_hibernate.UserDaoSupport">   
 <property name="sessionFactory">
   <ref bean="sessionFactory"/>
 </property>   
   </bean></beans>FactoryConfigDataSource.xml<beans.....................................

  <bean id="dataSource"
         ......................
         .....................
</bean> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean></beans>两个配置文件在同一包spring_unite_hibernate下面,为什么UserDAOSupport.xml的bean中引用FactoryConfigDataSource.xml中的sessionFactory 一直提示引用的bean‘sessionFactory’找不到

解决方案 »

  1.   

    错误提示:
    Loading XML bean definitions from URL [file:/G:/STSCode/hibernate_in_spring/build/classes/spring_unite_hibernate/spring_unite_hibernate/FactoryConfigDataSource.xml]
    Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring_unite_hibernate/FactoryConfigDataSource.xml]
    Offending resource: class path resource [spring_unite_hibernate/UserDAOSupport.xml]; nested exception is org.springframework.beans。。
      

  2.   

    错误提示:
    file:/G:/STSCode/hibernate_in_spring/build/classes/spring_unite_hibernate/spring_unite_hibernate/FactoryConfigDataSource.xml可能的问题:
    UserDAOSupport.xml
    <beans ...................   <import resource="spring_unite_hibernate/FactoryConfigDataSource.xml"/>
      

  3.   

    上面的问题已解决,去掉spring_unite_hibernate/就行,运行时继续报错:
    xception in thread "main" java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
    at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:323)
    at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:235)
    我用的是hibernate4.1.9spring用的3.2.0
    这个是什么情况??????????