Java file: Content not allowed in prolog

后端 未结 4 1579
有刺的猬
有刺的猬 2021-01-17 23:38

I\'m new to Spring and started using the Sprint Tool Suite (eclipse) and see this error in a java file in my maven project: \"Content is not allowed in prolog\". This preve

4条回答
  •  清酒与你
    2021-01-17 23:59

    Most likely the error was generated by the UTF-8 BOM at the start of the XML file - applications like Notepad puts that at the start of the file and the Java streams cannot handle that automatically. Your XMLis correct, but the file is not UTF-8Encoded. I've seen this before.. try copying and pasting the XML from this forum into a text editor and saving it. Also make sure that you're text editor is really saving in UTF-8.

    Also, Springwill work just fine without any declaration so go ahead and remove the comment between the DTDdeclaration and the starting element. Remove the UTF-8declaration. Problems with UTF-8encoded XMLin Java are pretty common, and not specific to Spring.

提交回复
热议问题