Announcement Announcement Module
Collapse
No announcement yet.
About spring-beans-2.5/3.0 Schemas Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • About spring-beans-2.5/3.0 Schemas

    Hello Guys

    I have the follow bean

    Code:
        <bean id="someBean"
            class="com.jordan.SomeBean"
            autowire="autodetect">
            <property name="...." value="..." />
              .....
        </bean>
    With
    Code:
    <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-2.5.xsd">
    work,

    but with
    Code:
    <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-3.0.xsd">
    instead I received

    Code:
    [java] INFO: Loading XML bean definitions from class path resource [beans.x
    ml]
    [java] Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
           Line 13 in XML document from class path resource [beans.xml] is invalid; 
           nested exception is org.xml.sax.SAXParseException: 
           cvc-enumeration-valid: 
           Value 'autodetect' is not facet-valid with respect to enumeration
           '[default, no, byName, byType, constructor]'. 
           It must be a value from the enumeration.
    [java]     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:378)
    Other case is the follow

    Code:
    <bean id="otherBean"
        class="com.jordan.OtherBean"
        autowire="byName" dependency-check="objects">
            <property name="...." value="..." />
              .....
    </bean>
    With 2.5 work, but with 3.0 instead I received

    [java] Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException:
    Line 13 in XML document from class path resource [beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException:
    cvc-complex-type.3.2.2:
    Attribute 'dependency-check' is not allowed to appear in element 'bean'.
    [java] at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:378)
    Is normal these behaviours with spring-beans-3.0.xsd?
    or I forgot something?

    Thanks in advanced

  • #2
    Originally posted by dr_pompeii View Post
    Is normal these behaviours with spring-beans-3.0.xsd?
    That's correct. These features are deprecated in Spring 3.0.

    By deprecated here, I mean that they are no longer supported in the 3.0 schemas; however, the functionality is still there and will apply when used with the 2.5 and 2.0 schemas.

    The rationale is to deprecate automagical pre-Java-5 container functionality that is based on not-too-obvious signature conventions and/or does not interoperate with newer annotation-based mechanisms nicely.

    This in particular includes autowire="autodetect" and the XML-driven dependency-check mechanism, for which "simple" and "objects" are not very specific ways of narrowing the properties to check and do not interoperate with the use of @Required, which is the preferred way of doing this now.

    In both cases, the Spring team recommends that you should rather use:
    • constructors exclusively,
    • setters with a dedicated init method implemented,
    • setters with @Required on required properties, or
    • @Autowired-driven injection

    Regards,

    Sam

    Comment


    • #3
      Be aware that the xsd files for 3.0 are not available at, e.g.

      - http://www.springframework.org/schema/aop
      - http://www.springframework.org/schema/beans
      - http://www.springframework.org/schema/context
      - http://www.springframework.org/schema/util
      - http://www.springframework.org/schema/tx

      Comment


      • #4
        Originally posted by Juergen.Zimmermann View Post
        Be aware that the xsd files for 3.0 are not available ...
        That's because 3.0 final has not yet been released.

        FYI: The default XSDs (i.e., ones without a qualifying version number in the file name) always match the current publicly released version of the framework.

        - Sam

        Comment


        • #5
          Hello Sam

          Thanks a lot for the reply and explanation, really valuable

          By deprecated here, I mean that they are no longer supported in the 3.0 schemas; however, the functionality is still there and will apply when used with the 2.5 and 2.0 schemas.
          Thats correct

          The rationale is to deprecate automagical pre-Java-5 container functionality that is based on not-too-obvious signature conventions and/or does not interoperate with newer annotation-based mechanisms nicely.
          I understood that the deprecated things were based or dedicated to work with jdk 1.4 series right?, of course in such series annotations doesnt exists yet, available since 1.5 series, but can you expand the idea with the bold part pls?, not very clear to me, years ago that I didnt work with 1.4 series, instead pure 1.5

          About this
          In both cases, the Spring team recommends that you should rather use:
          * constructors exclusively,
          * setters with a dedicated init method implemented,
          * setters with @Required on required properties, or
          * @Autowired-driven injection
          I understand, but for the the second point about its explanation with some sample code, where is located in Spring 3.0 documentation?
          and about @PostConstruct , is still recommended?

          I have many doubts,and how you are part of the Spring Team, your knowledge is valuable

          1) Is there a link to see all the new schemas created in Spring 3.0.0 serie release like spring-beans-3.0.xsd? or even better to see a complete relation for the track of version release for each schema? in a table of comparative behaviours/features among each version?
          2)Seems that new schemas 3.0 series are based to work with 1.5 (therefore some deprecated reasons), Are there new features available only for 3.0 series?
          3)The versions in 3.0 has the same behaviour and features with jdk 1.5 and 1.6 ?

          Thanks in advanced for your help and time

          Best Regards

          -Manuel

          Comment


          • #6
            What is funny though that as at time of this writing (2010-07-30, when not only Spring 3.0 final, but 3.0.3 already released) freshly downloaded Spring 3.0 Reference still has 'autodetect' in it without any mention of deprecation (chapter "Autowiring collaborators", p. 54 in the PDF version).

            Comment

            Working...
            X