报错
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