本文主要是介绍解决SpringBoot启动报错:Failed to load property source from location 'classpath:/application.yml',希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
《解决SpringBoot启动报错:Failedtoloadpropertysourcefromlocationclasspath:/application.yml问题》这篇文章主要介绍...
在启动SpringBoot项目时报如下错误

原android因可能是
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
conphpnection-tijsmeout: 60000
idle-timeout: 60000
validation-timeout: 3000
max-lifetime: 60000
login-timeout: 5
maximum-pool-size: 60
minimum-idle: 10
mvc:
http://www.chinasem.cnview:
prefix: classpath:/templates/
suffix: .html
dephpvtools:
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: debug2.yml文件格式是GBK
但是在yml中写了中文注释,如下图:

- a. 最直接的解决方法就是删除yml中的所有中文注释(简单粗暴直接);
- b. 修改yml文件的编码格式为utf-8
在File->Settings->Editor->File Encodings 里面设置编码格式为utf-8

总结
这篇关于解决SpringBoot启动报错:Failed to load property source from location 'classpath:/application.yml'的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!