How do I resolve the problem "xmlns" must be declared for element type "beans"?

494 Views Asked by At

I am trying to integrate struts2 with spring, but I got an error message like this.

2020-11-24 16:23:21,624 ERROR [main] context.ContextLoader (ContextLoader.java:313) - Context initialization failed org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 68; Attribute "xmlns" must be declared for element type "beans".

What is wrong with my applicationContext.xml?

This is my setting.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="helloWorldClass" class="org.mentha.example.HelloWorld" >
        <property name="message" value="Hello World! from arpit" />
    </bean>
</beans>

1

There are 1 best solutions below

0
On

before

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

using this one

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">