spring 配置文件的相互引用问题

danwell7 2013-02-28 09:50:58
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’找不到



...全文
138 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lvzg_005 2013-02-28
  • 打赏
  • 举报
回复
没有加载配置文件吧 把错误的详细信息贴出来
danwell7 2013-02-28
  • 打赏
  • 举报
回复
上面的问题已解决,去掉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 这个是什么情况??????????
「已注销」 2013-02-28
  • 打赏
  • 举报
回复
错误提示: 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"/>
danwell7 2013-02-28
  • 打赏
  • 举报
回复
错误提示: 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。。。。。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧