Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:06:55+00:00 2026-06-05T05:06:55+00:00

We use Spring dependency injection in a large web application. There are services which

  • 0

We use Spring dependency injection in a large web application. There are services which must work with request or session data and we implemented it with the javax.inject.Provider interface like this (We use constructor injection but in this example I inject the provider directly into a field so the example is shorter):

@Service
public class SomeService()
{
    @Autowired
    public Provider<Data> dataProvider;

    public void doSomething()
    {
        Data data = this.dataProvider().get()

        ...Do something with the request...
    }
}

In this example Data is some session-scoped data. The service itself is a singleton.

The problem now is that the dataProvider.get() call is WAY too slow. It needs several seconds to complete. I debugged the call and found out that the time is burned somewhere in the method DefaultListableBeanFactory.getBeanNamesForType. In this method a list of all bean definition names is fetched (Which contains more than 1000 names (We have lots of controllers, DAOs and services…) and iterated to find the bean to inject.

This is pretty much useless if it is that slow. I’m shocked that we have so many Spring beans already but isn’t there a way to improve the lookup speed of javax.inject.provider stuff or a nice different way to solve this kind of injection? Maybe there is some way to define our own provider implementations which Spring could inject so it doesn’t search for matching beans everytime the Provider.get() method is called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:06:57+00:00Added an answer on June 5, 2026 at 5:06 am

    The performance of DefaultListableBeanFactory.getBeanNamesForType was raised as an issue and has been fixed in Spring 3.2.

    The issue is here

    You can try the 3.2 M1 to see if it improves the situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simplified Architecture of Web Projects WAR spring dependency injection (most use XML) JAR DAO
I have a system which is using Spring for dependency injection. I use annotation-based
We are using Spring.NET for Dependency Injection and NHibernate as ORM. We use Session
I've always used Spring's dependency injection to get datasource objects and use them in
I use Spring MVC (via Spring Roo) to build a small web application for
is there a way to use dependency injection to inject all available implementations of
I was wondering if there were any dependency injection frameworks for use with development
Is there an easy way to use Spring IoC for a factory which returns
I'm trying to understand the best way to use Spring (for dependency injection) with
I wanted to create a Web-App that would use neo4j with Spring Data. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.