Tag Archives: Cannot find the declaration of element XXX

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

org/springframework/beans/factory/xml/

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

classpath:/org/springframework/beans/factory/xml/spring-beans-2.5.xsd

Instead of

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

Enables the configuration file to be read directly from the local

Reprint address: http://blog.csdn.net/wengang285/article/details/7587264

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” ” http://www.springframework.org/dtd/spring-beans-2.0.dtd “>
<beans>

Problem solving address: http://www.myexception.cn/vc-mfc/627052.html

 

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