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’找不到
错误提示:
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。。。。。
2013-02-28 17:57
提问者采纳
在web.xml中配置下 eg. <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> </context-param>
-
提问者评价
-
原来是这样,感谢!
评论
5
10


173万+

被折叠的 条评论
为什么被折叠?



