Error creating bean with name 'entityManagerFactory' defined in class path resource : Invocation of init method failed
I would start by adding the following dependency:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.4.Final</version>
</dependency>
and
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.3.Final</version>
</dependency>
UPDATE: Or simply add the following dependency.
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
Error creating bean with name 'entityManagerFactory' defined in class path resource (Invocation of init method failed)
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.
@Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
return sessionFactory;
}
but JPA by default search sessionFactory by name 'entityManagerFactory' so change my code as:
@Bean(name="entityManagerFactory")
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
return sessionFactory;
}
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
Spring boot Error creating bean with name 'entityManagerFactory' defined in class path resource
Your comment:
**Here I'm trying to do a "spring-boot:run" and want to generate columns for all above
five variables. But I'm getting this error :**
indicates that you want to have columns with the ids of the products and variants in your shopping table, however what you probably want to do is have a join table.
The error is telling you that your mapping is not understood, your use case should use a many to many relationship, and you will need a separate table to hold the foreign keys. Basically annotate the products and variants attributes with @ManyToMany and specify the join table, this is left as an exercise to you.
Check https://www.baeldung.com/jpa-many-to-many for an example
Error creating bean with name 'entityManagerFactory' defined in class path resource.No identifier specified for entity:
I had the same problem.
In my case,its because of wrong @Id annotation import.
It should be :- import javax.persistence.Id;
ref:-(https://stackoverflow.com/a/15323836/19262829)
Related Topics
Android "Gps Requires Access_Fine_Location" Error, Even Though My Manifest File Contains This
Failed to Install Android-Sdk: "Java.Lang.Noclassdeffounderror: Javax/Xml/Bind/Annotation/Xmlschema"
How to Set Timeout in Retrofit Library
Kafka - Unable to Send a Message to a Remote Server Using Java
What Is the Point of Heterogenous Arrays
Differencebetween Swing and Awt
How to Handle Windows File Upload Using Selenium Webdriver
How to Execute Cucumber Feature File Parallel
How to Randomize Two Arraylists in the Same Fashion
Read Content from Files Which Are Inside Zip File
Android M Permissions: Onrequestpermissionsresult() Not Being Called
How to Use Vectordrawable in Buttons and Textviews Using Android:Drawableright
Javafx Freeze on Desktop.Open(File), Desktop.Browse(Uri)
Aes Java Encoding, Ruby Decoding
Import Maven Dependencies in Intellij Idea