我希望將相同的EntityManagerFactory實例注入到兩個我的spring bean中。向兩個其他bean注入相同的bean實例
我嘗試:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="my-app"/>
</bean>
<bean id="serverDAO"
class="com.ehcachedemo.dao.ServerDAO">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="testServerDAO"
class="com.ehcachedemo.test.TestServerDAO">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
但在運行時,兩個差的EntityManagerFactory實例注入。有小費嗎?由於
爲什麼你認爲這些情況有什麼不同? – axtavt 2012-04-15 21:50:13