国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

啟動spring boot項目時加載配置文件報錯的問題

這篇具有很好參考價值的文章主要介紹了啟動spring boot項目時加載配置文件報錯的問題。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

最近把電腦重置了一下,然后重新安裝各種開發(fā)軟件,從gitee拉項目到本地運行時居然啟動報錯了:

Failed to load property source from 'file:/D:/program/IdeaProjects/layui/target/classes/application.yml'

這是加載配置文件的時候失敗了,提示一堆錯誤信息,但是沒有任何實質(zhì)性的幫助。

java.lang.IllegalStateException: Failed to load property source from 'file:/D:/program/IdeaProjects/layui/target/classes/application.yml' (classpath:/application.yml)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:553) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:498) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:468) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$7(ConfigFileApplicationListener.java:447) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_152]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$8(ConfigFileApplicationListener.java:447) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_152]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:444) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$0(ConfigFileApplicationListener.java:347) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.FilteredPropertySource.apply(FilteredPropertySource.java:54) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:335) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:226) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:210) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:200) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:188) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at cn.edu.sgu.www.layui.LayuiApplication.main(LayuiApplication.java:23) [classes/:na]
Caused by: org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
	at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:287) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:195) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:82) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:123) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:489) ~[snakeyaml-1.26.jar:na]
	at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:200) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:164) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:76) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:607) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:523) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	... 25 common frames omitted
Caused by: java.nio.charset.MalformedInputException: Input length = 1
	at java.nio.charset.CoderResult.throwException(CoderResult.java:281) ~[na:1.8.0_152]
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339) ~[na:1.8.0_152]
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) ~[na:1.8.0_152]
	at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[na:1.8.0_152]
	at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125) ~[snakeyaml-1.26.jar:na]
	at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183) ~[snakeyaml-1.26.jar:na]
	... 43 common frames omitted

導致種情況,就是配置文件有問題,首先檢查配置文件的格式是否正確(一般不是這個問題)。如果檢查完了啟動還是報錯,查看idea里的字符編碼

依次點擊File->Settings...打開idea的設(shè)置界面,在搜索框輸入enc,查詢出來的所有選項設(shè)置都點開看一下,看到Encoding的地方都改成UTF-8。

啟動spring boot項目時加載配置文件報錯的問題

注意:如果再次啟動項目還是報錯,把target目錄刪了再重新啟動一下。

好了,本次就分享到這里了,看完不要忘記點贊+收藏哦~文章來源地址http://www.zghlxwxcb.cn/news/detail-511494.html

到了這里,關(guān)于啟動spring boot項目時加載配置文件報錯的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務器費用

相關(guān)文章

  • idea中配置spring boot單項目多端口啟動

    idea中配置spring boot單項目多端口啟動

    參照文章 https://zhuanlan.zhihu.com/p/610767685 項目配置如下 下面為 idea 2023,不同版本的設(shè)置有區(qū)別,但是沒那么大,idea 2023默認使用新布局,切換為經(jīng)典布局即可。 在項目根目錄的.idea/workspace.xml文件里添加如下配置 外面的根節(jié)點為 project 指定一個啟動類后改名 勾選 Add VM option

    2024年02月05日
    瀏覽(26)
  • spring boot 啟動報錯---java: 無法訪問org.springframework.boot.SpringApplication 錯誤的類文件:

    spring boot 啟動報錯---java: 無法訪問org.springframework.boot.SpringApplication 錯誤的類文件:

    目錄 錯誤提示信息: 原因: 解決辦法: 具體步驟: 主要是因為 spring boot 3.0發(fā)布了 ,在創(chuàng)建項目時,默認為3.0 ` 但同時, spring boot 3.0 只支持jdk 17 ,在平時創(chuàng)建時,都喜歡使用jdk8 由于 spring boot 版本默認3.0,同時jdk選擇的是 8 ,就會導致這個錯誤 將 spring boot 版本和jdk統(tǒng)一

    2024年02月15日
    瀏覽(16)
  • Java企業(yè)級開發(fā)學習筆記(4.4)Spring Boot加載自定義配置文件

    Java企業(yè)級開發(fā)學習筆記(4.4)Spring Boot加載自定義配置文件

    創(chuàng)建 Spring Boot 項目 單擊【創(chuàng)建】按鈕 在 resources 里創(chuàng)建 myconfig.properties 文件 設(shè)置文件編碼 設(shè)置學生的四個屬性值 在 cn.kox.boot 包里創(chuàng)建config子包,在子包里創(chuàng)建 StudentConfig 打開自帶的測試類 ConfigDemo01ApplicationTests 注入學生配置實體,創(chuàng)建 testStudentConfig() 測試方法,在里面輸

    2024年02月08日
    瀏覽(27)
  • 使用nacos配置中心管理配置文件時,springcloud程序啟動報錯,無法找到對應的配置文件(加載到了錯誤的配置文件)

    使用nacos配置中心管理配置文件時,springcloud程序啟動報錯,無法找到對應的配置文件(加載到了錯誤的配置文件)

    1、將SpringBoot項目升級為SpringCloud 2、SpringBoot版本從 2.1.3.RELEASE 升級為 2.7.8 3、不使用Nacos配置中心,而是加載本地配置文件時,程序啟動正常 4、使用Nacos配置中心,加載到了錯誤的配置文件,導致程序啟動失敗 1、 bootstrap.yml 配置 2、查看Nacos配置中心 2.1、 group 和 namespace 都沒

    2024年02月04日
    瀏覽(28)
  • Spring Boot學習隨筆- @SpringBootApplication詳解、加載絕對路徑配置文件、工廠創(chuàng)建對象(@ConfigurationProperties、@Value)

    Spring Boot學習隨筆- @SpringBootApplication詳解、加載絕對路徑配置文件、工廠創(chuàng)建對象(@ConfigurationProperties、@Value)

    學習視頻:【編程不良人】2021年SpringBoot最新最全教程 這是一個 組合注解 ,就是由多個注解組成。下列注解紅框內(nèi)稱為 元注解 (jdk提供) @Target :指定注解作用范圍 @Retention :指定注解什么時候生效 重要注解 @SpringBootConfiguration:自動配置Spring、SpringMVC相關(guān)環(huán)境 @EnableAutoCo

    2024年02月05日
    瀏覽(59)
  • 【Spring Boot學習一】創(chuàng)建項目 && Spring Boot的配置文件

    【Spring Boot學習一】創(chuàng)建項目 && Spring Boot的配置文件

    目錄 一、安裝插件 二、創(chuàng)建Spring Boot項目 1、創(chuàng)建項目 1.1?使用IDEA創(chuàng)建 ?1.2?網(wǎng)頁版本創(chuàng)建 2、項目目錄介紹與運行 三、Sping Boot的配置文件(重點) ??1、.properties配置文件 (1)基礎(chǔ)語法:Key = value (2)讀取配置?件中的內(nèi)容,@Value 注解使?“${}”的格式讀??; ??2、.y

    2024年02月16日
    瀏覽(38)
  • Spring Boot項目在Windows上的自啟動策略與Windows自動登錄配置

    Spring Boot項目在Windows上的自啟動策略與Windows自動登錄配置

    ???? 博主貓頭虎 帶您 Go to New World.??? ?? 博客首頁——貓頭虎的博客?? ??《面試題大全專欄》 文章圖文并茂??生動形象??簡單易學!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍專欄》學會IDEA常用操作,工作效率翻倍~?? ?? 《100天精通Golang(基礎(chǔ)入門篇)》學會Golang語言

    2024年02月07日
    瀏覽(30)
  • 聊聊Spring Boot配置文件:優(yōu)先級順序、加載順序、bootstrap.yml與application.yml區(qū)別詳解

    在 Spring Boot 中,配置文件的優(yōu)先級順序是: application-{profile}.yml ( application-{profile}.properties ) application.yml ( application.properties ) bootstrap.yml ( bootstrap.properties )。其中, {profile} 表示不同的環(huán)境配置,如 dev 、 test 、 prod 等。 優(yōu)先級從高到低,高優(yōu)先級的配置覆蓋低優(yōu)先級

    2024年01月25日
    瀏覽(31)
  • 詳解 Spring Boot 項目中的配置文件

    詳解 Spring Boot 項目中的配置文件

    ?????? 點進來你就是我的人了 博主主頁: ?????? 戳一戳,歡迎大佬指點! 歡迎志同道合的朋友一起加油喔 ?????? 目錄 1. Spring Boot 項目中配日文件的作用是什么 2. Spring Boot 配置文件的兩種格式 1. properties的語法 2. yml的語法 3. properties與yml的對比 4. 設(shè)置不同環(huán)境下的配

    2024年02月08日
    瀏覽(28)
  • 【Spring Boot】Spring Boot自動加載機制:簡化應用程序的啟動

    在微服務盛行的今天,快速搭建和啟動應用程序變得至關(guān)重要。Spring Boot作為Java生態(tài)系統(tǒng)中主流的框架,其自動加載機制使得開發(fā)者能夠快速構(gòu)建和啟動應用程序。本文將詳細介紹Spring Boot的自動加載機制,并通過代碼示例加以說明。 首先,我們要了解Spring Boot自動加載機制

    2024年02月11日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包