Spring boot启动报异常‘FAILED TO LOAD PROPERTY SOURCE FROM LOCATION 'CLASSPATH:/APPLICATION.YML’

学习springboot,在启动时抛出下图异常'

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'

at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:524)

at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:473)

at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:443)

at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:425)

at java.lang.Iterable.forEach(Iterable.java:75)

往下看异常信息,找到异常的具体位置


首行报出: Failed to load property source from location 'classpath:/application.yml' 在尾部可以看到报出出错位置:line8,colum 9


在搭建数据库信息时从第八行的头部位置多了一个空格导致启动失败,多一个空格或者少一个空格都会引起此报错导致启动失败。


去掉空格,项目就可以正常运行了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容