Attribute "scope" must be declared for element type "bean"-[spring]
2012-09-27 14:04
525 查看
今天在做spring测试的时候,发现这个错误:
[java] Caused by: org.xml.sax.SAXParseException: Attribute "scope" must be
declared for element type "bean".
截图:
这个错误查了一下:原来Attribute "scope" 在spring2.0以后支持啊~~
spring的XML配置文件的这个:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
改成这个就可以了:
<?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">
附录:
XML配置
Spring 2.0的XSD在描述Spring XML元数据格式方面比先前的DTD更丰富。 旧的DTD仍然得到支持,但如果可能我们鼓励在bean定义文件头部引用XSD文件。
有一点被改变了,那就是定义bean作用域的方式。如果你使用的是Spring 1.2 DTD,那么你能继续用'singleton'属性。 如果你选择引用新的Spring 2.0 DTD,它不允许使用'singleton'属性,
那么可以用'scope'属性来定义bean的生命周期作用域。
文章来源:百度空间
[java] Caused by: org.xml.sax.SAXParseException: Attribute "scope" must be
declared for element type "bean".
截图:
这个错误查了一下:原来Attribute "scope" 在spring2.0以后支持啊~~
spring的XML配置文件的这个:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
改成这个就可以了:
<?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">
附录:
XML配置
Spring 2.0的XSD在描述Spring XML元数据格式方面比先前的DTD更丰富。 旧的DTD仍然得到支持,但如果可能我们鼓励在bean定义文件头部引用XSD文件。
有一点被改变了,那就是定义bean作用域的方式。如果你使用的是Spring 1.2 DTD,那么你能继续用'singleton'属性。 如果你选择引用新的Spring 2.0 DTD,它不允许使用'singleton'属性,
那么可以用'scope'属性来定义bean的生命周期作用域。
文章来源:百度空间
相关文章推荐
- Attribute "scope" must be declared for element type "bean"
- Attribute "scope" must be declared for element type "bean"
- Attribute "scope" must be declared for element type "bean"
- scope" must be declared for element type "bean"异常
- 【hibernate】Attribute "column" must be declared for element type "property"解决办法
- Attribute "column" must be declared for element type "property"解决办法
- spring mvc web.xml 配置出现 Attribute "xmlns:xsi" must be declared for element type "web-app"
- Attribute "resultCalss" must be declared for element type "select".
- org.xml.sax.SAXParseException: Attribute "colum" must be declared for element type "result".
- ERROR [ValidatorFileParser] Attribute "short-circuit" must be declared forelement type "field-validator".
- "scope" must be declared for element type "bean"异常
- FAQ(4):Attribute "resource" must be declared for element type "mapper".
- Attribute "resource" must be declared for element type "mapper".
- Attribute "resultType" must be declared for element type "insert".
- Attribute "result" must be declared for element type "select".
- web.xml中的web-app中出现Attribute "xsi:schemaLocation" must be declared for element type "web-app".
- Attribute "resultClass" must be declared for element type "insert".
- Attribute "resultClass" must be declared for element type "insert".
- Attribute "resultType" must be declared for element type "update" or "insert"
- [报错]Attribute "xmlns:xsi" must be declared for element type "web-app"