创建spring boot后启动报错: Failed to bind properties under ‘spring.datasource‘

2023-11-06

这种问题在于我们使用.yml文件时候的格式出现了问题造成的

我们深入探讨一下

application.properties与application.yml之间的区别:

看了一篇文章说以前一直用的是application.properties,接触了application.yml后,感觉yml比properties好用,更有层次性,一眼看去更清晰明了!properties文件都需要写全,yml前面相同的可以不写,一层对应一层就好了。

我们用idea生成spring boot 框架里面是.properties的。

application.properties

application.yml

在yml文件中有些细节需要注意,冒号后面要空一格再写值,虽然在IDE中都会自动空一格。

 

现在再看我们开发发生的问题 就是这里没有空格或者格式不对

spring boot服务启动时,如果报出如下错误:

Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties或

Failed to bind properties under 'spring.datasource' to org.springframework.boot.autoconfig.jdbc.DataSourceProperties

解决方案为:

检查配置文件配置的格式是否正确,配置文件为application.yml或者是application.properties,大部分是.myl格式不整齐,不正确。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

创建spring boot后启动报错: Failed to bind properties under ‘spring.datasource‘ 的相关文章

随机推荐