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 8040367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:52:23+00:00 2026-06-05T03:52:23+00:00

To provide some runtime generated API documentation I want to iterate over all Spring

  • 0

To provide some runtime generated API documentation I want to iterate over all Spring MVC controllers. All controllers are annotated with the Spring @Controller annotation. Currently I do it like this:

for (final Object bean: this.context.getBeansWithAnnotation(
        Controller.class).values())
{
    ...Generate controller documentation for the bean...
}

But the first call of this code is EXTREMELY slow. I wonder if Spring iterates over ALL classes in the classpath instead of just checking the defined beans. The controllers are already loaded when the above code is run, the log displays all of them with their request mappings so Spring MVC must already know them all and there must be a faster way to get a list of them. But how?

  • 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-05T03:52:25+00:00Added an answer on June 5, 2026 at 3:52 am

    I have also came across such requirement before some months and I have achieved it using the following code snippet.

    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
            scanner.addIncludeFilter(new AnnotationTypeFilter(Controller.class));
            for (BeanDefinition beanDefinition : scanner.findCandidateComponents("com.xxx.yyy.controllers")){
                System.out.println(beanDefinition.getBeanClassName());
            }
    

    You can also do something like this with your controllers.

    Updated the code snippet. Removed the not necessary code and just displaying the class name of the controllers for better understanding.
    Hope this helps you. Cheers.

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

Sidebar

Related Questions

I need to provide some passwords, API keys and similar sensitive data in my
I've been asked to provide some tricky printing functionality to a dynamicly generated page.
I want to know about Binary Runtime Environment for Wireless tutorial(Brew). Any one provide
Can anyone provide some links to good information on setting up Silverlight 2.0 to
Can anyone provide some information on how to run an integration services package, on
Could someone provide some example on implementing SEH in VB6? Everything I've seen so
Can i provide some algorithm for generate smth intead of FK030HF9840303 for example?
Can anybody provide some details on <:< operator in scala. I think: if(apple <:<
I have been taken in to provide some SEO guidance on a website which
I'm trying to write a plugin system to provide some extensibility to an application

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.