xml - NoSuchBeanDefinitionException caused by nested bean definition for Spring JPA -


spring jpa 4.2.1

nested bean definition looks below gets nosuchbeandefinitionexception:

"no qualifying bean of type [javax.persistence.entitymanagerfactory] defined"

<bean id="tm" class="...jpatransactionmanager">     <property name="entitymanagerfactory">         <bean class="...localcontainerentitymanagerfactorybean">             <property name="datasource">                 <bean class="...basicdatasource"                     p:driverclassname="..." p:url="...">                 </bean>             </property>         </bean>     </property> </bean> 

only flat definition works below, why?

<bean id="tm" class="...jpatransactionmanager">     <property name="entitymanagerfactory" ref="emf" /> </bean> <bean id="emf" class="...localcontainerentitymanagerfactorybean">     <property name="datasource" ref="ds" /> </bean> <bean id="ds" class="...basicdatasource"     p:driverclassname="..." p:url="..."> </bean> 

some other bean requires entitymanagerfactory (which one, can't - didn't show full stack trace). , inner beans anonymous , can't retrieved using beanfactory.getbean() or @autowired, that's why error in first case.

inner beans always anonymous , always created outer bean. not possible inject inner beans collaborating beans other enclosing bean.

in second case entitymanagerfactorybean not inner bean , can used other bean.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -