浏览 749 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-07-19
项目之前建立在struts2+spring2+hibernate3基础上,因为要在view上显示关联对象属性值,用了opensessioninview,一切正常。
现在把后面改成jpa模式,用实体来操作dao,也用上了annotation,关于spring配置文件如下,运行时出现 引用 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
其实原先的配置是有sessionFactory的。我想问的是在struts2+spring2+jpa模式下,如何使用opensessioninview,如何配置,谢谢各位交流。 <?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@192.168.0.12:1521:ora" />
<property name="username" value="xxx" />
<property name="password" value="xxx" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="adminService" class="com.xxx.service.impl.AdminServiceImpl" />
<bean id="adminAction" class="com.xxx.action.AdminAction" scope="prototype">
<constructor-arg ref="adminService" />
</bean>
</beans>
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
时间:2007-07-19
哈哈,我知道了,原来应该用OpenEntityManagerInViewFilter来实现,具体配置就不说了。
PS:我搜索了下OpenEntityManagerInViewFilter这个关键字,居然javaeye里面没有这个关键词(内容查找也是),呵呵。 |
|
| 返回顶楼 | |
|
时间:2007-07-19
说明还没流行
|
|
| 返回顶楼 | |





