温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

spring boot yml怎么配置

发布时间:2021-06-30 15:33:33 来源:亿速云 阅读:235 作者:chen 栏目:大数据

本篇内容主要讲解“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怎么配置”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI