A component required a bean named entitymanagerfactory that could not be found
A component required a bean named entitymanagerfactory that could not be found
Spring-boot: required a bean named ‘entityManagerFactory’ that could not be found
I am developing a Spring Boot application using JPA and encountering this error. I am not certain if I am using the correct annotations or missing dependencies. Any help would be greatly appreciated.
This is the error message
build.gradle
application.properties
Application.java
UserService.java
UserServiceImpl.java
UserRepository.java
User.java
11 Answers 11
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
I was getting error message like-
required a bean named ‘entityManagerFactory‘ that could not be found.
After lot of googling solve this problem. I set manual configuration for JPA.
but JPA by default search sessionFactory by name ‘entityManagerFactory‘ so change my code as:
For me, I’ve forgotten to remove DataSourceAutoConfiguration.class from exclusions.
Run into same issue when trying to connect spring boot to mysql database.
What saved me was adding correct version of hibernate-core to my pom file. From hibernate onwards 5.2.0. hibernate-entitymanager is no longer needed. Hibernate-core 5.2.0 have problem with Spring Data JPA while process collection. Hibernate-core 5.2.1 and above is ok with Spring Data JPA if you are using Spring Data JPA.
in our case was working fine but not for tests with @WebMvcTest
Took a while to find out but issue was:
You either need to remove exclude =
UPDATE: Seems like you have some mistakes in your properties:
Try to remove the extra = from the first line and use spring.datasource.driver-class-name property name for the second:
Also add a version to your MySQL dependency:
I think that because of these mistakes Spring is unable to autodetect your datasource type correctly.
You have chosen to bypass auto creation of EntityManagerFactory. Therefore you should add folowing two beans in one of your configuration classes, possibly in Application class.
Don’t forget to add the hibernate dependency to your project.
In my case the problem was exclude =
I’m using spring boot 2.1.11.RELEASE version.
Programming is something funny, once I used the exclude solution to solve an error message, then the same thing was the problem now. So there’s no magic spell or formula as this universe has lots and lots of different scenarios, even if it’s similar to a previous one we worked on.
EntityManagerFactory not found in SpringBoot
I am trying to create a login for employees, using MySQL and SpringBoot. I made my code work using an in-memory Database, but as soon as I switched my code to MySQL, it stopped working. This project is a Frankenstein, so I am not sure whether some of my components can work together. I am not sure whether all the annotations in my App class are needed. The error is the following:
Consider defining a bean named ‘entityManagerFactory’ in your configuration.
Here is my App class, that runs the whole thing:
And here is the XML file and the properties file:
Where should the entityManager be? And how should I make it considering my project is very simple for now (has a service, control, employee and app classes)
4 Answers 4
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Remove this line @EnableAutoConfiguration(exclude =
It looks like you have included the mysql:mysql-connector-java dependency and that is good. Make sure you have done a maven update on your project if it was recently added so that it will be added to your classpath.
Your properties should look like this
com.mysql.jdbc.Driver depends on the mysql:mysql-connector-java dependency.
UPDATE (after git inspection):
I updated application.properties to reflect the changes notated above.
I removed the methods from UserRepository and updated UserService to handle those changes.
Consider defining a bean named ‘entityManagerFactory’ in your configuration. #10
Comments
sathishkumarkk commented Mar 11, 2018 •
The text was updated successfully, but these errors were encountered:
dsyer commented Mar 11, 2018
Works for me. What did you do exactly?
sathishkumarkk commented Mar 11, 2018 •
dsyer commented Mar 11, 2018
May I know what would cause such an application failure?
The error diagnostic is quite clear («hello.MainController required a bean named ‘entityManagerFactory'»). If you don’t have one you aren’t running the same app as me.
Which code are you running exactly? Maybe clear your Maven cache and try again to be on the safe side?
helsonxiao commented Mar 28, 2018
dsyer commented Mar 28, 2018
I think it must be a bad jar file.
paritoshh commented Nov 22, 2018
kullov commented Dec 5, 2018
How about your project? I have the same issue!
praful09534 commented Dec 25, 2018
I have exactly the same issue and tried all the possible solutions mentioned on the net. Still, the issue is not fixed. Please suggest a proper solution. Any help would be highly appreciated.
polaroi8d commented Jan 6, 2019
dsyer commented Jan 6, 2019
There is no issue in the code for this guide. If you have a bad jar the best thing to do is delete it and let it be downloaded again.
joker7blue commented Feb 5, 2019
It’s simple, i have solved my issue..
Add this dependency in your pom.xml
janarrdhan commented Mar 4, 2019 •
still i have the issue,please help me.
Field userRepository in com.b2b.services.security.CustomAppUserDetailsService required a bean named ‘entityManagerFactory’ that could not be found.
The injection point has the following annotations:
— @org.springframework.beans.factory.annotation.Autowired(required=true)
Consider defining a bean named ‘entityManagerFactory’ in your configuration.
photoTed commented Mar 22, 2019
Not sure if it helps or is the same issue: I was getting the same error in a project with two manually configured datasources and inadvertently had both identified as @primary. Once I removed that annotation from one, the error went away.
GanDigit commented May 10, 2019
If you have a Wrapper class for Id field in your entity class, convert that into primitive.
petertogara commented May 17, 2020
whats the difference there?
sajis79 commented Aug 17, 2020
amitsingh6764 commented Sep 5, 2020
I have same issue.any Idea how to solve?
muthu1712 commented Sep 7, 2020
Same issue here.
petertogara commented Sep 7, 2020
ok, let me test and see if that works.
petertogara commented Sep 7, 2020
change Long to long and see as suggested by @GanDigit
muthu1712 commented Sep 8, 2020
I had two datasources defined in my code, but missed to specify which should be primary one. Once i added the @primary annotation, the issue was fixed.
Thanks anyway @petertogara 🙂
pMan commented Oct 15, 2020
If you are using ‘spring-boot-starter-jdbc’ and ‘javax.persistence-api’ in your pom by mistake, replace them with ‘spring-boot-starter-data-jpa’. Just in case.
raviredddy5209 commented Dec 28, 2020
Please help with the issue
dsyer commented Dec 28, 2020
WuIsGoing commented Mar 9, 2021
chenlangping commented Mar 26, 2021
It worked for me. But which jar file is the bad jar? I want to know.
bondress commented Apr 30, 2021
org.hibernate hibernate-entitymanager 5.2.3.Final
This was very helpful. Thanks @joker7blue
joker7blue commented Apr 30, 2021
org.hibernate hibernate-entitymanager 5.2.3.Final
This was very helpful. Thanks @joker7blue
akm1007 commented May 7, 2021
sheetalj2205 commented Jun 6, 2021
hey! how to delete all and install them again?
wanisramdani commented Jun 18, 2021
rpcabrera commented Sep 29, 2021
I had two datasources defined in my code, but missed to specify which should be primary one. Once i added the @primary annotation, the issue was fixed. Thanks anyway @petertogara 🙂
It worked for me! In my case I’m using two different datasources, but as I’m defining them with JpaRepositories I need to configure manually (using Bean annotation of course) in a configuration class the Entity Manager (EM) and the Transaction Manager (TM). So the problem in my case is that the EM & TM should be marked with @primary annotation too, not only the Datasource.
Field repository in » required a bean named ‘entityManagerFactory’ that could not be found
I started having this problem, but could not find the solution to it. I stumbled upon some similar problems online with the same error, but none of them gave my solution, everything seems normal in my project.
This is the error on output:
This are the files of my project (file tree):
This is my code:
What could be the issue?
1 Answer 1
This bean definition is usually provided automatically by Spring Boot Auto-Configuration. The spring reference manual explains how to diagnose such issues:
The Spring Boot auto-configuration tries its best to “do the right thing”, but sometimes things fail, and it can be hard to tell why.
There is a really useful ConditionEvaluationReport available in any Spring Boot ApplicationContext. You can see it if you enable DEBUG logging output. If you use the spring-boot-actuator (see the Actuator chapter), there is also a conditions endpoint that renders the report in JSON. Use that endpoint to debug the application and see what features have been added (and which have not been added) by Spring Boot at runtime.
Many more questions can be answered by looking at the source code and the Javadoc. When reading the code, remember the following rules of thumb:
As you can tell from the ConditionalOnClass annotation, this configuration is only applied if your classpath contains the classes LocalContainerEntityManagerFactoryBean from spring-orm-jpa, EntityManager from the JPA spec, and SessionImplementor from the hibernate jar.
Most likely, you are missing one of these JAR files (maven dependencies), or have the wrong version of one. The ConditionEvaluationReport should tell you which, and the precise package names to check for.
A required bean can not be found during tests / No bean named ‘entityManagerFactory’ available
I am developing a small app just to try Spring boot on my own. It has five different modules (eclipse projects):
model—contains entity classes, DTO’s and mappers to switch between them
service—contains services and their implementations
reserve-management—contains the controller for the reservations and the spring app itself
person-management—contains the controller for the people data and the spring app itself
If I start either of the apps, they run just fine but when developing tests for them I always get this exception:
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
[spring-test-5.3.21.jar:5.3.21] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
[na:na] at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
[na:na] at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
[na:na] at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[na:na] at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[na:na] at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
[na:na] at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
[na:na] at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
[na:na] at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
[na:na] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at java.base/java.util.Optional.orElseGet(Optional.java:369)
[na:na] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:102)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66)
[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
[junit-platform-engine-1.8.2.jar:1.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
[na:na] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
[junit-platform-engine-1.8.2.jar:1.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
[na:na] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60)
[junit-platform-launcher-1.8.2.jar:1.8.2] at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
[.cp/:na] at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
[.cp/:na] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘reservesServiceImpl’: Unsatisfied dependency expressed through field ‘reserveRepo’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.hotel.data.reserve.ReservesRepository’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: <@org.springframework.beans.factory.annotation.Autowired(required=true)>at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
[spring-context-5.3.21.jar:5.3.21] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
[spring-context-5.3.21.jar:5.3.21] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132)
[spring-boot-test-2.7.1.jar:2.7.1] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
It also tells me that I should add a bean of type ReservesRepository in my configuration.
I have removed methods from classes for brevity.
Источники информации:
- http://stackoverflow.com/questions/45350546/entitymanagerfactory-not-found-in-springboot
- http://github.com/spring-guides/gs-accessing-data-mysql/issues/10
- http://stackoverflow.com/questions/71638518/field-repository-in-required-a-bean-named-entitymanagerfactory-that-could-n
- http://stackoverflow.com/questions/73051540/a-required-bean-can-not-be-found-during-tests-no-bean-named-entitymanagerfact