SpringBoot JPA Hibernate: Error creating bean with name 'entityManagerFactory'

No, the problem is not in the connection of the database. Hibernate determines its policy to check the configuration annotations based on the annotation place on the id (on the attribute itself or on a method).

In your User class, you are telling hibernate to expect the annotations on the attribute level.

public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="user_id")
private int id;

So for hibernate you do not have a mapping for other attribute like roles because it will not check the methods for the mapping, so what you need to do is to take the annotation from the method and put it in the attribute.

@ManyToMany
@JoinTable(name="user_role", joinColumns = @JoinColumn(name="user_id"), inverseJoinColumns = @JoinColumn(name="role_id"))
private Set<Role> roles;

You need to do this in all your annotations.


If there is a mapping exception along with above mentioned exception, the problem can be with Jdk 11 and javassist.

Need to add this in pom.xml

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.23.1-GA</version>
</dependency>