Results 1 to 2 of 2

Thread: Naming a bean using @Bean?

  1. #1

    Default Naming a bean using @Bean?

    It looks like it should be fairly easy to add the ability to name a bean using the @Bean annotation. Is there a reason this does not seem to have been done and would not be a good idea? (if there is already a way to name beans then my apologies and I would appreciate a docs link)

    I certainly understand using the BeanNamingStrategy as a way to generally override default naming but it seems like a weakness to not be able to name beans when defining them.

  2. #2
    Join Date
    Apr 2007
    Posts
    307

    Default

    You're quite right to expect this, and it's a gap in functionality right now. I'd appreciate it if you'd add a JIRA issue to this effect.

    In the meantime, you can use the @Bean(aliases="customName") as a workaround. It will mean that the bean is registered under both names (from the method and from the alias) which may or may not work for you.
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •