jpa.adapter.springjpaadapter中构造函数的参数0需要一个名为' entityManagerFactory'找不到
当我用@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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论