gpt4 book ai didi

java - spring-mvc 3.0.5 : what's the preferred way to instantiate the JPA entity manager

转载 作者:行者123 更新时间:2023-12-01 19:21:09 26 4
gpt4 key购买 nike

我当前的工作代码:

EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("TT-SpringMVCPU");
EntityManager em = emf.createEntityManager();

我想用这样的东西替换它:

@PersistenceContext(unitName = "TT-SpringMVCPU")
private EntityManager _entityManager;

当我尝试这样做时,我收到此错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'showController': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'TT-SpringMVCPU' is defined
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:341)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
...

我忘记配置什么?

最佳答案

关于java - spring-mvc 3.0.5 : what's the preferred way to instantiate the JPA entity manager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4180691/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com