title: How does ComponentScan work?
body: <p><code>@ComponentScan</code> will give you a list of all the classes with the <code>@Component</code> annotation in a package (or <code>@Service</code>/<code>@Repository</code>). To do this I imagine they use reflection to enumerate all the classes in a package and find the ones with that annotation.</p>
  
  <p>However according to <a href="https://stackoverflow.com/questions/520328/can-you-find-all-classes-in-a-package-using-reflection">other StackOverflow answers</a> you can not reliably enumerate all the classes in a package due to how the <code>ClassLoader</code>works. So how does <code>@ComponentScan</code> seemingly manage to accomplish this?</p>