If there is no configuration error in your project and the configuration file name is normal, and this problem still occurs, it must be the problem of your YML file coding
Attach a project architecture diagram first
When I start the server to find the configuration file, the server prompts such an error message
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application-dev.yml' at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:549) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:488) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:468) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:450) at java.lang.Iterable.forEach(Iterable.java:75) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$7(ConfigFileApplicationListener.java:449) at java.lang.Iterable.forEach(Iterable.java:75) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:446) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:336) at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:215) at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:198) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:185) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:171) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:361) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) at com.dawn.rockcandy.RockCandyApplication.main(RockCandyApplication.java:11) Caused by: org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1 at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:254) at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:58) at org.yaml.snakeyaml.Yaml.loadAll(Yaml.java:537) at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:166) at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:139) at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:75) at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:567) at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:523) ... 23 common frames omitted Caused by: java.nio.charset.MalformedInputException: Input length = 1 at java.nio.charset.CoderResult.throwException(CoderResult.java:281) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) at java.io.InputStreamReader.read(InputStreamReader.java:184) at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125) at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:223) ... 31 common frames omitted
My application.yml and application-dev.yml have no configuration errors, and my file name is completely normal. There is also application-dev.yml in the compiled target file. I wonder where the problem is!
Open the target file and check the application-dev.yml file. It is found that the file is empty, indicating that the file compilation failed!!!
Finally, the problem is found because the encoding format of this file is GBK and the encoding format of the project is UTF-8. There are comments in it. The comments are garbled, resulting in compilation failure
1. Modify your coding format
2. Delete comments
Similar Posts:
- Springboot startup error yamlexception/malformedinputexception input length = 1
- org.springframework.core.log.LogMessage [How to Solve]
- [Solved] org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key
- [Exception] LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either r…
- [Solved] Logback configuration error: SLF4J: Class path contains multiple SLF4J bindings.
- An error occurs when springboot sets the log level [How to Solve]
- Springboot starts with @ scheduled and reports an error: no qualifying bean
- [Solved] linux Error: springboot org.springframework.context.ApplicationContextException: Failed to start bean ‘webServerStartStop’
- [Solved] Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
- Springboot Failed to parse configuration class [x]