学习springboot时,这个问题困扰好久啊!
方法1:重新加载jpa更改pom文件里的内容:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
然后clean-编译
如果还是解决不了
方法二:
看连接的数据源是否配置错误:
我的application.yml文件内容,尤其注意空格问题
server:
port: 8888
spring:
profiles:
active: dev
datasource:
driver-class-name:
com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
username: root
password: root
jpa:
hibernate:
ddl-auto: create
show-sql: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: UTC
还有个问题就是我的配置文件无法跳转到生产环境:
原因就是因为我在idea里,Edit Configurations-spring boot-****Application-Environment variables里配置了固定的值;
符:application-dev.yml内容:
server:
port: 8082
gril:
age: 18
application-prod.yml
server:
port: 8080
gril:
age: 18