How to Solve Error: Cannot find the declaration of element ‘beans’.

Question: org.xml.sax .SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.

Solution: first, if the exception is encountered in the project, it is usually the problem that the project cannot download to the spring-beans-2.5.xsd file. The version number here varies with the project version.

Here you need to configure the local XSD file as follows:

Find the core package of spring referenced in your project, spring.jar

Open it with a compressed file and find the path


And configure the XSD file in this path to applicationContext.xml If there are more than one configuration file, all of them will be replaced

That is to say,
is the best choice


Instead of

Enables the configuration file to be read directly from the local

Reprint address:

Method 2:

Modify spring applicationContext.xml Change the name space of the XML file to the following code:

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN 2.0//EN” ” “>

Problem solving address:


The first method seems to have no effect, so I use the second method to solve the problem

Read More: