解决org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method ‘entityManagerFactory’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘entityManagerFactoryBuilder’ defined in class path resource
总之就是解决和entityManager这个bean创建有关的问题,这可能不仅仅是entityManager,还可能是Factory、Builder等。
这里面最大的问题就是,你的mysql连接有很大问题,可能的原因有:
- mysql连接写错了,重点关注一下其符号啊、连接端口号啊、连接的数据库到底是哪一个
- 查看报错信息,如果是java.sql.SQLException: Access denied for user ‘root’@‘localhost’ (using password: YES)。那么就是可能你的数据库密码输入错误了。
- 加入依赖,包括jpa等,不要加错了。
- 最最重要的是,自己看一下报错信息,不能只看到这个entity相关的错,可能前面就有真正源头的错误,实在找不到可以自己打个断点一步一步走