您好,登錄后才能下訂單哦!
本篇內容主要講解“spring boot yml怎么配置”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“spring boot yml怎么配置”吧!
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml' at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:465) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:386) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:225) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.24.RELEASE.jar:4.3.24.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.24.RELEASE.jar:4.3.24.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.24.RELEASE.jar:4.3.24.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122) ~[spring-context-4.3.24.RELEASE.jar:4.3.24.RELEASE] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:296) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at com.hr.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.21.RELEASE.jar:1.5.21.RELEASE] Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation) in 'reader', line 2, column 1: port: 8888 ^ at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:585) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:157) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:147) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:246) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:237) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:225) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:84) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:104) ~[snakeyaml-1.17.jar:na] at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:471) ~[snakeyaml-1.17.jar:na] at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:157) ~[spring-beans-4.3.24.RELEASE.jar:4.3.24.RELEASE] at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:135) ~[spring-beans-4.3.24.RELEASE.jar:4.3.24.RELEASE] at org.springframework.boot.env.YamlPropertySourceLoader$Processor.process(YamlPropertySourceLoader.java:101) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:58) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.env.PropertySourcesLoader.load(PropertySourcesLoader.java:128) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.doLoadIntoGroup(ConfigFileApplicationListener.java:490) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:473) ~[spring-boot-1.5.21.RELEASE.jar:1.5.21.RELEASE] ... 22 common frames omitted
yml需要在 “:” 后加一個空格,幸好 IDEA 很好地支持了 yml 文件的格式有良好的代碼提示;
換行時不能使用tab而是用空格縮進
到此,相信大家對“spring boot yml怎么配置”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。