title: Spring - scanning for beans
body: <p>I am a bit puzzled about Spring bean-scanning.</p>
  
  <p>AFAIK I need to put <code>&lt;context:component-scan base-package="some.package" /&gt;</code></p>
  
  <p>and Spring will search from the root of a given package for beans.</p>
  
  <p>But now in my application, if I delete this line from .xml configuration file, and start up Tomcat I get</p>
  
  <pre><code>INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4dd1b: defining beans
  </code></pre>
  
  <p>and then I get a long list of beans, some of them are from Spring, but also there are those that would I would expect to see with <code>&lt;context:component-scan base-package="some.package" /&gt;</code> added to config file. The only thing that is different between both logs, is the mapping of the controller methods to addresses. Methods are not mapped if this line is not present.</p>
  
  <p>Why Spring is detecting those beans? What is making Spring scan my packages for annotated classes?</p>
  
  <p>If it is relevant I am using Spring 3</p>
  
  <p>EDIT:
  if I don't remove <code>&lt;context:component-scan base-package="some.package" /&gt;</code> I am getting information about pre-instantiating singletons twice. So it looks like those beans are scanned two times.</p>
  
  <p>EDIT:
  It seems that in one of the files loaded by ContextListener I had component-scan. That is why I had those beans listed twice.</p>