Skip to content
Advertisement

Error creating bean with name ‘entityManagerFactory’ defined in class path resource (Invocation of init method failed)

When I try to run my spring-boot project with hibernate and MySql, I got following error.

JavaScript

My application.properties

JavaScript

In pom.xml I have following dependencies,

JavaScript

and my Course model looks like below,

JavaScript

I also referred previous questions(Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed) regarding this issue, But nothing helps.

Full code base is available at https://github.com/tenusha/application-frameworks/tree/master/spring-boot-mysql

Advertisement

Answer

some day ago i am 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.

JavaScript

but JPA by default search sessionFactory by name ‘entityManagerFactory’ so change my code as:

JavaScript

my previous answer


UPDATE import proper calss

import javax.persistence.Id;

you try to join subject class with course without foreign key reference… change your code according that image

enter image description here

Advertisement