Problem Description: When using Springboot to integrate Redis for YML configuration, start Project error, prompting to load application.yml configuration file failed:
-: -:27.430[Main] ERROR Org.springframework.boot.SpringApplication-application startup failedjava.lang.IllegalStateException: Failed to the Load property source from location 'classpath:/application.yml'At Org.springframework.boot.context.Config. Configfileapplicationlistener$loader.loadintogroup (Configfileapplicationlistener.java:476) at Org.springframework.boot.context.Config. Configfileapplicationlistener$loader.load (Configfileapplicationlistener.java:465) at Org.springframework.boot.context.Config. Configfileapplicationlistener$loader.load (Configfileapplicationlistener.java:386) at Org.springframework.boot.context.Config. Configfileapplicationlistener.addpropertysources (Configfileapplicationlistener.java:225) at Org.springframework.boot.context.Config. Configfileapplicationlistener.postprocessenvironment (Configfileapplicationlistener.java:195) at Org.springframework.boot.context.Config. Configfileapplicationlistener.onapplicationenvironmentpreparedevent (Configfileapplicationlistener.java:182) at Org.springframework.boot.context.Config. Configfileapplicationlistener.onapplicationevent (Configfileapplicationlistener.java:168) at Org.springframework.context.Event. Simpleapplicationeventmulticaster.invokelistener (Simpleapplicationeventmulticaster.java:167) at Org.springframework.context.Event. Simpleapplicationeventmulticaster.multicastevent (Simpleapplicationeventmulticaster.java:139) at Org.springframework.context.Event. Simpleapplicationeventmulticaster.multicastevent (Simpleapplicationeventmulticaster.java:122) at Org.springframework.boot.context.Event. Eventpublishingrunlistener.environmentprepared (Eventpublishingrunlistener.java: About) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared ( Springapplicationrunlisteners.java: Wu) at Org.springframework.boot.SpringApplication.prepareEnvironment (Springapplication.java:325) at Org.springframework.boot.SpringApplication.run (Springapplication.java:296) at Org.springframework.boot.SpringApplication.run (Springapplication.java:1118) at Org.springframework.boot.SpringApplication.run (Springapplication.java:1107) at Com.zhaopin.ImccApplication.main (Imccapplication.java:Ten) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (Nativemethodaccessorimpl.java: +) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (Delegatingmethodaccessorimpl.java: +) at Java.lang.reflect.Method.invoke (Method.java:498) at Com.intellij.rt.execution.application.AppMain.main (Appmain.java: $) caused by:org.yaml.snakeyaml.parser.ParserException: whileparsing Mappingnode in'Reader', line the, column1: Server:^Duplicate key:spring in'Reader', line -, column1: ^At Org.springframework.beans.factory.Config. Yamlprocessor$strictmapappenderconstructor.constructmapping (Yamlprocessor.java:411) at Org.yaml.snakeyaml.constructor.safeconstructor$constructyamlmap.construct (Safeconstructor.java:489) at Org.yaml.snakeyaml.constructor.BaseConstructor.constructObject (Baseconstructor.java:182) at Org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument (Baseconstructor.java:141) at Org.yaml.snakeyaml.constructor.BaseConstructor.getData (Baseconstructor.java:108) at org.yaml.snakeyaml.yaml$1. Next (Yaml.java:471) at Org.springframework.beans.factory.Config. Yamlprocessor.process (Yamlprocessor.java: the) at Org.springframework.beans.factory.Config. Yamlprocessor.process (Yamlprocessor.java:138) at Org.springframework.boot.env.yamlpropertysourceloader$processor.process (Yamlpropertysourceloader.java: 101) at Org.springframework.boot.env.YamlPropertySourceLoader.load (Yamlpropertysourceloader.java: -) at Org.springframework.boot.env.PropertySourcesLoader.load (Propertysourcesloader.java:127) at Org.springframework.boot.context.Config. Configfileapplicationlistener$loader.doloadintogroup (Configfileapplicationlistener.java:490) at Org.springframework.boot.context.Config. Configfileapplicationlistener$loader.loadintogroup (Configfileapplicationlistener.java:473) ... +Common frames omittedprocess finished with exit code1
APPLICATION.YML configuration:
Note that there are two spring-based configuration items in the diagram that do not conform to the YML configuration syntax, so start an error.
Workaround: Modify the YML configuration file to look like this, and then start the Springboot project without an error:
Use Springboot's yml file configuration when stepping on a pit