【问题标题】:nested exception is org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 128; cvc-elt.1: Cannot find the declaration of element 'beans'嵌套异常是 org.xml.sax.SAXParseException;行号:3;列号:128; cvc-elt.1:找不到元素“bean”的声明
【发布时间】:2018-01-12 05:45:28
【问题描述】:

我正确添加了 xsi:schemaLocation,但它显示错误

<beans xmlsn="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="welcomebean"    class="com.sathya.beans.WelcomeBean">
    <property name="message"    value="welcome to Spring"></property>   
    </bean>

</beans>

【问题讨论】:

  • 您遇到的错误是什么?

标签: java xml spring


【解决方案1】:

&lt;beans xmlsn="..."&gt; 更改为&lt;beans xmlns="..."&gt;

【讨论】:

  • 现在出现这样的错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'WelcomeBean' available package com.sathya.beans;这是我的 WelcomeBean 类 public class WelcomeBean { private String message; public void setMessage(String message) { this.message=message; } public void showMessage() { System.out.println("Message="+message); } }
猜你喜欢
  • 1970-01-01
  • 2015-08-11
  • 2020-12-09
  • 2011-10-31
  • 1970-01-01
  • 1970-01-01
  • 2017-02-05
  • 2020-05-08
  • 2015-11-25
相关资源
最近更新 更多