Skip to content

Configurable bean initialization order [SPR-3948] #8628

@spring-projects-issues

Description

@spring-projects-issues

Bernard Macours opened SPR-3948 and commented

There should be a way to order bean initialization. Using "depends-on" is too verbose and is forcing us to explicitly bind business beans with technical beans:

<bean name="my-technical-bean"/>
<bean name="my-business-bean-1" depends-on="my-technical-bean"/>
<bean name="my-business-bean-2" depends-on="my-technical-bean"/>

It would be better to have something like:

<bean name="my-technical-bean" init-order="0"/>
<bean name="my-business-bean-1"/>
<bean name="my-business-bean-2"/>

Of course, we could configure several beans with a different initialization order. For example:
<bean name="my-technical-bean-a" init-order="0"/>
<bean name="my-technical-bean-b" init-order="1"/>

Note: "init-order" would be meaningless for lazy-initialized beans.


Affects: 2.0.6

4 votes, 5 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions