扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
本篇内容主要讲解“spring boot yml怎么配置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“spring boot yml怎么配置”吧!
创新互联建站主营克东网站建设的网络公司,主营网站建设方案,成都App定制开发,克东h5微信小程序开发搭建,克东网站营销推广欢迎克东等地区企业咨询
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怎么配置”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流