您当前的位置: 首页 >  hibernate

Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfigurat

梁云亮 发布时间:2020-04-30 00:03:52 ,浏览量:3

报错

pom.xml加入了jpa的引用, 项目启动时会去读yml或properties文件里的jdbc配置,没有就报错:Error creating bean with name ‘org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration’: Unsatisfied dependency expressed through constructor parameter 0;

在这里插入图片描述

解决方案

只需要加入相应的jar包并把jpa、datasource配好后就可以了:

server:
  port: 80
  servlet:
    context-path: /hv
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/db_test?useSSL=false&serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&allowPublicKeyRetrieval=true
    username: root
    password: root
    type: com.alibaba.druid.pool.DruidDataSource

注:上面连接url最后面的allowPublicKeyRetrieval=true必须加上否则有可能会报错:java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

关注
打赏
1688896170
查看更多评论

梁云亮

暂无认证

  • 3浏览

    0关注

    1121博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0806s