Tag Archives: xml

[Solved] Ideal Integrate Mybatis.xml File Error: BindingException: Invalid bound statement (not found):

Screenshot of error reporting

Checked the corresponding namespace

Corresponding target directory

Next, the path of the configuration file is checked

When it is found that none of the four conventional methods can solve the problem, consider whether it is the
POM file screenshot caused by jar package conflict

Sure enough, I use mybatis plus, but I use the startup jar package of mybatis. Replace it with mybatis plus boot starter, and comment out all related mybatis. The problem is solved.

Error in mybatis mapping .XML File [How to Solve]

In the mybatis framework, the test is carried out in the Dao layer, and the console displays an error: the attribute “resulttype” must be declared for the element type “delete”

The SQL statement of the corresponding. XML file is:

The detailed error messages on the console are:

1. Attribute ‘resulttype’ must be declared for element type ‘Delete’

2.

Check the information on the Internet and say that every_In the sqlmapper.xml file, try to match each SQL statement to a namespace (the complete Java class of each Dao layer); As a result, the attempt was unsuccessful

Finally, simply_Delete the resulttype in the sqlmapper.xml file, and the test is successful; Delete as shown:

Successful test chart:

1 is to get the spring container

2 is the number of deleted data in the test (the number of deleted data in the first test is 1), and this result is the second test

 

XML parsing & special character error

In XML files, some symbols have special meanings. If they are used directly, XML parsing errors will be reported. In order to avoid errors, we need to operate special characters with their corresponding escape entities. These characters are as follows

<   ==  & amp; lt;

>   ==  & amp;>

& ==   & amp; amp;   // & XML is used to escape. If it is used directly, an error will be reported, and its escaped characters must be used

‘   == & amp; apos;

”   ==  & amp; quot;

[Solved] DOM parsing XML Error: Content is not allowed in prolog

The error contents are:

Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.

The online summary is   the analysis content contains BOM  。 This tag is invisible. There is only this tag in the stream.
BOM: byte order mark, Chinese name, byte order mark. The UCS specification recommends that the BOM be transmitted before the byte stream is transmitted to judge the byte order.
in fact, UTF-8 does not need BOM to indicate the byte order, but BOM can be used to indicate the encoding method. The UTF-8 code of BOM is EF BB BF. Therefore, if the receiver receives the byte stream beginning with EF BB BF, it indicates that it is UTF-8 code

solution:

if you are parsing a file  :

You can use UltraEdit or emeditor to open XML and save it as. When saving, you can choose whether to save it in UTF-8 without BOM or UTF-8 with BOM

 

if the content is returned from a remote request:

If you change the returned stream new to a string, you will not see the BOM, but you must intercept the content you need:

if(null != result && !"".equals(result)){ if(result.indexOf("<") != -1 && result.lastIndexOf(">") != -1 && result.lastIndexOf(">") > result.indexOf("<")) result = result.substring(result.indexOf("<"), result.lastIndexOf(">") + 1); }

It is also said that it is caused by the lower version of Dom4j, but I have seen that the version I use is 1.6.1, so this possibility is excluded, but in practice, I still recommend using the latest stable version for development

XML(xsd):Failed to read schema document [How to Solve]

 

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">

The above bank reported the following errors:

Multiple annotations found at this line:
 - cvc-elt.1: Cannot find the declaration of element 'ehcache'.
 - schema_reference.4: Failed to read schema document 'http://ehcache.org/ehcache.xsd', because 1) could not find the document; 
 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

Solution (introduce xsd locally).

1. Add a new file ehcache.xsd in the project, and fill the file “http://ehcache.org/ehcache.xsd” with the contents of ehcache.xsd in

2、Location: select this xsd file Key type: Schema location
Key:http://ehcache.org/ehcache.xsd

[Solved] XML Read Error: Invalid byte 1 of 1-byte UTF-8 sequence

XML reading exception invalid byte 1 of 1-byte UTF-8 sequence

 

To put it simply, when you parse someone else’s XML format, this error may be that someone else did not save the UTF-8 character encoding format when generating XML

In the Chinese version of window, the default encoding of Java is GBK, that is, although we have identified that we want to save XML in UTF-8 format, in fact, the file is saved in GBK format, so this is why we can use GBK and GB2312 encoding to generate XML files, which can be correctly parsed, while the file generated in UTF-8 format cannot be parsed by XML parser

 

Encoding exception encountered during XML parsing:

org.dom4j.DocumentException: Invalid byte 1 of 1-byte UTF-8 sequence. Nested exception: Invalid byte 1 of 1-byte UTF-8 sequence.
	at org.dom4j.io.SAXReader.read(SAXReader.java:484)
	at org.dom4j.io.SAXReader.read(SAXReader.java:321)
	at com.dataoperate.PaseXml.pXml(PaseXml.java:28)
	at com.dataoperate.JdbcOp.insertDb(JdbcOp.java:30)
	at com.dataoperate.JdbcOp.main(JdbcOp.java:89)
Nested exception: 
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:684)
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:554)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1742)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(XMLEntityScanner.java:487)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2687)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.dom4j.io.SAXReader.read(SAXReader.java:321)
	at com.dataoperate.PaseXml.pXml(PaseXml.java:28)
	at com.dataoperate.JdbcOp.insertDb(JdbcOp.java:30)
	at com.dataoperate.JdbcOp.main(JdbcOp.java:89)
Nested exception: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:684)
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:554)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1742)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(XMLEntityScanner.java:487)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2687)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.dom4j.io.SAXReader.read(SAXReader.java:321)
	at com.dataoperate.PaseXml.pXml(PaseXml.java:28)
	at com.dataoperate.JdbcOp.insertDb(JdbcOp.java:30)
	at com.dataoperate.JdbcOp.main(JdbcOp.java:89)

solve:

1. The simplest is to <?xml version=”1.0″ encoding=”UTF-8″?> Change to<?xml version=”1.0″ encoding=”gbk”?>

2. Or change the character set of XML to UTF-8 and save it

3. When parsing the code, rewrite the XML first

SAXReader reader = new SAXReader();  
  org.dom4j.Document document = reader.read("D:\\ha.xml");  
  OutputFormat of = new OutputFormat();  
  of.setEncoding("UTF-8"); 
  XMLWriter writer = new XMLWriter(new FileWriter "d:\\dom4j.xml"), of);

4. When reading Dom4j directly, use IO to read and modify the character code

FileInputStream in = new FileInputStream(new File(fileName));
Reader read = new InputStreamReader(in,"gbk");
Document document = reader.read(read);

 

 

 

 

NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;

When the Android project is running on Android 9.0, it will flash back and report the following error

Java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;

terms of settlement:

Add the

<uses-library android:name="org.apache.http.legacy" android:required="false" />

Contribution by aizier River