spring jpa multiple entityManagerFactory,没有

时间:2016-09-29 11:17:04

标签: spring jpa

我在jpa中使用了多个entitymanger

这是jpa存储库。

jpa:repositories base-package="com.wallet.repositories" entity-manager-factory-ref="entityManagerFactory" 
    transaction-manager-ref="transactionManager" 

    jpa:repositories base-package="com.cas.entity" entity-manager-factory-ref="casentityManagerFactory" transaction-manager-ref="castransactionManager"

我得到了“没有[com.cas.repositories.AccountRepository]类型的限定bean”

这是accountrepo类

import com.cas.entity.Account;


public interface AccountRepository extends CrudRepository<Account, Long>, JpaSpecificationExecutor<Account> {

    @Query("select a from Account a where a.accountNo=?1")
    Account findByAccountNo(String accountNo);
}

请参阅下面的详细信息

  

**** org.springframework.beans.factory.BeanCreationException:创建名为'CasAccountApi'的bean时出错:注入自动装配   依赖失败;嵌套异常是   org.springframework.beans.factory.BeanCreationException:不能   autowire字段:private com.cas.repositories.AccountRepository   com.cas.api.impl.AccountApi.accountRepository;嵌套异常是   org.springframework.beans.factory.NoSuchBeanDefinitionException:没有   找到[com.cas.repositories.AccountRepository]类型的限定bean   对于依赖:预计至少有1个bean有资格作为autowire   这种依赖的候选人。依赖注释:   {@ org.springframework.beans.factory.annotation.Autowired(所需=真)}     在   org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:301)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1186)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)     在   org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:302)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)     在   org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)     在   org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)     在   org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)     在   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)     在   org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)     在   org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)     在   org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)     在   org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)     在   org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)     在   org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)     在   org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)     在   org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)     在   org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)     在   org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)     在   org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)     在   org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)     在org.eclipse.jetty.server.Server.doStart(Server.java:282)at   org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)     在   net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)     在   net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)     在   net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)****

提前致谢

0 个答案:

没有答案