在启动springboot项目时报如下错误
原因可能是
1.yml中语法错误
(特别注意:在yml中key与value之间是有一个空格的),仔细检查一下语法
server: port: 8090 #在这里,key值与value之间有有一个空格 spring: application: name: demo datasource: username: root password: root driver-class-name: com.mysql.jdbc.driver url: jdbc:mysql://localhost:3308/test?characterencoding=utf8&usessl=false&allowmultiqueries=true&usejdbccomplianttimezoneshift=true&uselegacydatetimecode=false&servertimezone=asia/shanghai hikari: read-only: false connection-timeout: 60000 idle-timeout: 60000 validation-timeout: 3000 max-lifetime: 60000 login-timeout: 5 maximum-pool-size: 60 minimum-idle: 10 mvc: view: prefix: classpath:/templates/ suffix: .html devtools: restart: enabled: true mail: default-encoding: utf-8 host: smtp.qq.com protocol: smtp username: password: properties: mail: smtp: auth: true starttls: enable: true required: true mybatis: mapper-locations: classpath:mapper/*.xml type-aliases-package: com.example.demo.vo logging: level: com.example.demo.mapper: debug
2.yml文件格式是gbk
但是在yml中写了中文注释,如下图:
- a. 最直接的解决方法就是删除yml中的所有中文注释(简单粗暴直接);
- b. 修改yml文件的编码格式为utf-8
在file->settings->editor->file encodings 里面设置编码格式为utf-8
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论