cvc-complex-type.3.2.2: Attribute 'singleton' is not allowed to appear in element 'bean'
来源:互联网 发布:淘宝客做什么网站 编辑:程序博客网 时间:2024/05/18 15:07
spring2与spring1的单例模式配置的区别。
Spring 1.*
<bean id="hibernateSessionFactory" class="org.hibernate.admin.component.HibernateSessionFactory" init-method="init" destroy-method="dispose" singleton="true">
Spring 2.*
spring-beans-2.0.dtd/xsd does not support singleton="true"/"false" anymore. Use scope="singleton/"prototype" instead!
<bean id="hibernateSessionFactory" class="org.hibernate.admin.component.HibernateSessionFactory" init-method="init" destroy-method="dispose" scope="singleton">
如果在spring2.*中使用spring1.*的单例属性便会报错:org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'singleton' is not allowed to appear in element 'bean'.
在spring2.*中,bean没有“singleton”这个属性,而是在“scope”中对它进行设定。“scope”可以设定为 “singleton”和“prototype”默认情况下是“singleton”即和原先的“singleton=true”性质一样,如果要实现单例模式则将“scope”设定为“prototype”,即和原先版本的“singleton=false”一样。
Table 3.4. Bean作用域
singleton
在每个Spring IoC容器中一个bean定义对应一个对象实例。
prototype
一个bean定义对应多个对象实例。
request
在一次HTTP请求中,一个bean定义对应一个实例;即每次HTTP请求将会有各自的bean实例, 它们依据某个bean定义创建而成。该作用域仅在基于web的Spring ApplicationContext情形下有效。
session
在一个HTTP Session中,一个bean定义对应一个实例。该作用域仅在基于web的Spring ApplicationContext情形下有效。
global session
在一个全局的HTTP Session中,一个bean定义对应一个实例。典型情况下,仅在使用portlet context的时候有效。该作用域仅在基于web的Spring ApplicationContext情形下有效。
- cvc-complex-type.3.2.2: Attribute 'singleton' is not allowed to appear in element 'bean'
- cvc-complex-type.3.2.2: Attribute 'singleton' is not allowed to appear in element 'bean
- cvc-complex-type.3.2.2: Attribute 'content-negotiation-manager' is not allow
- cvc-complex-type.4: Attribute ‘version’ must appear on element ‘web-app’.
- Java--cvc-complex-type.4:Attribut ‘version’ must appear on element ‘web-app’
- cvc-complex-type.2.4.a: Invalid content was found starting with element 'attribute'. One of '{"http:
- SAXParseException: cvc-complex-type.3.2.2&&Document root element "beans", must match DOCTYPE root "null"
- cvc-complex-type.2.3:Element \'filter-mapping\' cannot have character [children],because the type\'s content type is element-onl
- nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'beans' cannot have
- cvc-complex-type.2.4.c: ...is strict, ...declaration found element"context:property-placeholder"
- The prefix "p" for attribute "p:myservice-ref" associated with an element type "bean" is not bound.
- cvc-complex-type.2.3: Element 'beans' cannot have character [children]
- cvc-complex-type.2.3: Element 'beans' cannot have character [children]
- - cvc-complex-type.2.3: Element 'web-app' cannot have character
- cvc-complex-type.2.3: Element 'web-app' cannot have character
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
- cvc-complex-type.2.4.c:The matching wildcard is strict,but no declaration can be found for element '
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
- 位运算应用口诀和实例
- linux 查看进程cpu和内存占用率排序
- 27款经典的CSS框架
- MultiselectItemSelector多选框
- ARM之汇编学习---如何编写ARM汇编程序
- cvc-complex-type.3.2.2: Attribute 'singleton' is not allowed to appear in element 'bean'
- Linux——linux学习全攻略 (转)
- 开博日
- 使用Javascript开发移动应用程序
- 快速上手老马在线客服系统
- LNMP一键安装包 0.6 正式发布
- Makefile 的书写规则
- Java生成mdb文件[MS Access文件](转载)
- 建议学习jQuery的步骤!