spring 配置文件的相互引用问题
UserDAOSupport.xml<beans...................<importresource="spring_unite_hibernate/Fa...
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。。。。。 展开
< 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。。。。。 展开
2个回答
展开全部
在web.xml中配置下
eg.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
</context-param>
eg.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
</context-param>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询