java.nio.charset.MalformedInputException: Input length = 1

Project scenario:

Using springboot to build a personal blog system
reference video: reference video link

Problem Description:

Error reported:

20:40:41.091 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
	at org.yaml.snakeyaml.reader.StreamReader.update(
	at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(
	at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(
	at org.yaml.snakeyaml.reader.StreamReader.peek(
	at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(
	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(
	at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(
	at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(
	at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(
	at org.yaml.snakeyaml.composer.Composer.checkNode(
	at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(
	at org.yaml.snakeyaml.Yaml$1.hasNext(

Cause analysis:

I remember converting the suffixes of properties files to YML files directly according to the video, and then the Chinese comments on the page became garbled, so I naturally converted them to GBK format, and then the above error was reported

The first possibility is that there is a problem with the encoding format of your application.yml file, which is changed to UTF-8
the second possibility is that your application.yml file is generated by directly changing the suffix of other types of files to YML. At this time, you need to copy all the contents in application.yml, delete them, and then create a new application.yml file, Copy the copied content into it and then run the project, and no error will be reported.


Find file coding in the setting of idea

Convert GBK to UTF-8, and then rewrite the Chinese annotation to run normally

Read More: