jpa.adapter.springjpaadapter中构造函数的参数0需要一个名为' entityManagerFactory'找不到

发布于 2025-01-19 09:25:59 字数 1899 浏览 1 评论 0原文

当我用@springboottest(class = bootloaderloaderapplicationlauncher.class,webenvironment = springboottest.webenvironment.random_port.random_port.random_port)我的测试通行证时,我正在尝试在测试类中测试控制器,在测试类中测试。用@webmvctest(controllers = relevebancairecontrollerimpl.class)我的应用程序抛出以下例外:

Parameter 0 of constructor in persistence.jpa.adapter.ReleveBancaireSpringJpaAdapter required a bean named 'entityManagerFactory' that could not be found.


Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

我使用maven多模块。

启动应用程序时,我添加了所有配置。
我只想用@webmvctest
测试控制器 春季启动版:2.3.1.Release
Hibernate-entityManager版本:5.0.0.-Final
Hibernate-core版本:5.6.5.

最终完全异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'releveBancaireRepository': Cannot create inner bean '(inner bean)#3c81cd82' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3c81cd82': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3c81cd82': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

I'm trying to test my controller, in my test class when I annotate it with @SpringBootTest(classes = BootloaderApplicationLauncher.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) my test pass but when I try to annotate it with @WebMvcTest(controllers = ReleveBancaireControllerImpl.class) my application throws this exception:

Parameter 0 of constructor in persistence.jpa.adapter.ReleveBancaireSpringJpaAdapter required a bean named 'entityManagerFactory' that could not be found.


Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

I using maven multi modules.
I added all my configuration when I start the application works fine.
I just want to test my controller with @WebMvcTest
Spring boot version: 2.3.1.RELEASE
hibernate-entitymanager version: 5.0.0.Final
Hibernate-core version: 5.6.5.Final

Full exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'releveBancaireRepository': Cannot create inner bean '(inner bean)#3c81cd82' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3c81cd82': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3c81cd82': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文