新建SpringBoot项目报错
📅 2021-09-13 10:42
👁️ 195
💬 0
新建一个Springboot项目时,当勾选了SQL相关的依赖(如引入了jpa 或MyBatis依赖),直接启动项目时报错
原因:没有配置数据库相关的属性,如 url driver 等
解决办法:在application.properties 中设置数据库链接的相关属性
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mytest?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
登录后才能查看或发表评论, 立即 登录