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

See original GitHub issue
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

2018-03-11 16:15:22.152  INFO 12204 --- [           main] hello.Application                        : Starting Application on Sathish-Lenovo-PC with PID 12204 (C:\Users\SathishKumar\Documents\workspace-sts-3.9.2.RELEASE\gs-accessing-data-mysql\complete\target\classes started by SathishKumar in C:\Users\SathishKumar\Documents\workspace-sts-3.9.2.RELEASE\gs-accessing-data-mysql\complete)
2018-03-11 16:15:22.152  INFO 12204 --- [           main] hello.Application                        : No active profile set, falling back to default profiles: default
2018-03-11 16:15:22.183  INFO 12204 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6295d394: startup date [Sun Mar 11 16:15:22 IST 2018]; root of context hierarchy
2018-03-11 16:15:23.096  INFO 12204 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5d19f29e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-11 16:15:23.451  INFO 12204 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-03-11 16:15:23.478  INFO 12204 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-03-11 16:15:23.479  INFO 12204 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
2018-03-11 16:15:23.483  INFO 12204 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_45\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8.0_45/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_45/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_45/bin/../jre/lib/amd64;C:\Program Files (x86)\Skype\Phone\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\SathishKumar\AppData\Local\Microsoft\WindowsApps;;C:\WINDOWS\System32;;.]
2018-03-11 16:15:23.591  INFO 12204 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-03-11 16:15:23.591  INFO 12204 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1408 ms
2018-03-11 16:15:23.716  INFO 12204 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-03-11 16:15:23.716  INFO 12204 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-11 16:15:23.716  INFO 12204 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-03-11 16:15:23.716  INFO 12204 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-03-11 16:15:23.716  INFO 12204 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-03-11 16:15:23.778  WARN 12204 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#344561e0' 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)#344561e0': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
2018-03-11 16:15:23.778  INFO 12204 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-03-11 16:15:23.794  INFO 12204 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-03-11 16:15:23.841 ERROR 12204 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field userRepository in hello.MainController required a bean named 'entityManagerFactory' that could not be found.


Action:

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:33

github_iconTop GitHub Comments

49reactions
joker7bluecommented, Feb 5, 2019

It’s simple, i have solved my issue… Add this dependency in your pom.xml

<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>5.2.3.Final</version> </dependency>

46reactions
GanDigitcommented, May 10, 2019

If you have a Wrapper class for Id field in your entity class, convert that into primitive.

--------------------- Wrong --------------------- @Entity public class Customer {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name = "name")
private String name;

--------------------- Correct --------------------- @Entity public class Customer {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
@Column(name = "name")
private String name;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Data JPA - Consider defining a bean named ...
I am developing an application in Spring, using Tomcat, Mysql5, Java8... The problem is that I cannot deploy it, due to "required bean...
Read more >
Java – Spring Boot: Consider defining a bean named ...
Java – NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' is defined. You're missing completly DB configuration in your Config class.
Read more >
spring-projects/spring-boot - Gitter
Action: Consider defining a bean named 'entityManagerFactory' in your configuration. Christian Bürckert.
Read more >
Consider defining a bean of type in your configuration Field ...
spring #springboot #error #springerror #springbooterror # bean #field # configuration Instagram: ...
Read more >
67. Data Access - Spring
To take full control of the configuration of the EntityManagerFactory , you need to add a @Bean named 'entityManagerFactory'. Spring Boot auto-configuration ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found