一、在學(xué)習(xí)SpringBoot配置profile的時(shí)候,.yml文件內(nèi)容明明跟老師敲的一模一樣,但還是報(bào)org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles' imported from location 'class path resource [application.yml]' is invalid and should be replaced with 'spring.config.activate.on-profile' [origin: class path resource [application.yml] - 21:13]錯(cuò)誤
二、.yml文件源代碼
--- server: port: 8081 spring: profiles: dev --- server: port: 8082 spring: profiles: pro --- server: port: 8083 spring: profiles: test --- spring: profiles: active: test
三、報(bào)如下錯(cuò)誤
四、問題原因
通過Debug運(yùn)行提示:?should be replaced with 'spring.config.activate.on-profile'(需要你改為現(xiàn)在的這種代碼格式)
五、改完后源代碼
--- server: port: 8081 spring: config: activate: on-profile: dev --- server: port: 8082 spring: config: activate: on-profile: pro --- server: port: 8083 spring: config: activate: on-profile: test --- spring: profiles: active: test
六、運(yùn)行結(jié)果
七、反思
當(dāng)按照老師講的走時(shí),遇到問題,需要及時(shí)通過Debug提示信息來找錯(cuò)誤,不要死腦筋,一直檢查代碼錯(cuò)誤。這次問題出在版本的原因。文章來源:http://www.zghlxwxcb.cn/news/detail-570576.html
我們需要養(yǎng)成會(huì)看代碼提示來進(jìn)行解決問題的習(xí)慣,腦子要靈活點(diǎn)。?文章來源地址http://www.zghlxwxcb.cn/news/detail-570576.html
到了這里,關(guān)于SpringBoot:解決Property ‘spring.profiles‘ imported from location ‘class path resource 問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!