【问题标题】:How do I resolve the problem "xmlns" must be declared for element type "beans"?如何解决必须为元素类型“beans”声明“xmlns”的问题?
【发布时间】:2021-03-07 00:34:34
【问题描述】:

我正在尝试将 struts2 与 spring 集成,但我 收到这样的错误消息。

2020-11-24 16:23:21,624 错误 [main] context.ContextLoader (ContextLoader.java:313) - 上下文初始化失败 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自 ServletContext 资源 [/WEB-INF/applicationContext.xml] 的 XML 文档中的第 8 行无效;嵌套异常是 org.xml.sax.SAXParseException;行号:8;列号:68;必须为元素类型“beans”声明属性“xmlns”。

我的 applicationContext.xml 有什么问题?

这是我的设置。

<?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>

【问题讨论】:

  • 使用spring框架解析xml配置文件的时候应该澄清一下你的问题。

标签: xml spring xml-namespaces xml-configuration


【解决方案1】:

之前

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

使用这个

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 2019-11-20
    • 1970-01-01
    相关资源
    最近更新 更多