在SpringBoot项目中,有时候很久没启动一个项目,再去启动时,有时候会报这样的错误:
错误:Caused by: java.nio.charset.MalformedInputException: Input length = 1
解决方案
如果是Maven的项目先clean一下,如果不好使,则修改pom.xml
在
<properties></properties>
中间添加一下代码:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
完整的如下:
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
重新刷新加载一下Maven,重启项目即可!