欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Spring 2.0 RC4 Released: Heads-up on DTD/Schema Renaming, Scope Attribute

程序员文章站 2023-12-30 17:09:28
...

Engineering
Colin Sampaleanu
September 17, 2006

Spring Framework 2.0 RC4 has been released. This is the last release candidate before Spring 2.0 final, and you may find out more about it from the release announcement itself as well as the JIRA issue list for a complete list of changes in this release.

Possibly the most important thing to watch out for is that this release introduces versioned file/location names for the 2.0 DTD and Schemas (XSDs). This was necessary since the XML bean definition format was significantly enahnced for 2.0, but 1.2.x users still need to be able to refer to the 1.2.8 DTD. Here is an example of using the 2.0 “beans” schema (2.0 ships with a number of other new schemas as well, representing various special namespaces):

<?xml version="1.0" encoding="UTF-8"?>

 <!-- Define your beans here -->

Here is an example of using the 2.0 DTD (there is only one DTD, you must switch to schema to get the various new namespaces):

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Define your beans here -->

One important thing to watch out for: any existing 1.2.x bean definition file should continue to work as is, since it is pointing to the 1.2 DTD, and all functionality is still supported. To get new 2.0 functionality supported by the new 2.0 DTD or schemas, you need to update your definition files as per the above examples. You also must switch from using the singleton attribute to define bean scopes, to using the new scope attribute instead. The old singleton and scope attributes overlap, and it was considered acceptable to remove the singleton attribute completely in the new DTD/schema definiitons, since the only people affected are people already changing their bean definition files to point to the new DTDs and schemas anyway. So if all you do is modify your existing bean definition files to point to the new DTD or schemas, without fixing up any use of singleton, you will get validation errors!

The new versioned DTD and schemas have been uploaded and are available online. While Spring itself finds the definitions within its own jar file (from the classpath) using an entity resolver, these definitions are needed online for XML Editors and other external users.
comments powered by Disqus

上一篇:

下一篇: