title: Declaration of beans and Dao classes in Spring
body: <p>Spring give the facility of defining beans class and DAO classes in application-context.xml file right now i am defining the bean classes like that</p>
  
  <pre><code>&lt;context:component-scan base-package="com.forum.jsfbeans" /&gt;
  </code></pre>
  
  <p>But many places in google i saw people defined DAO,beans,Service classes differently something like this  </p>
  
  <pre><code>&lt;!-- Beans Declaration --&gt;
      &lt;bean id="User" class="com.otv.model.User"/&gt;
  
      &lt;!-- User Service Declaration --&gt;
      &lt;bean id="UserService" class="com.otv.user.service.UserService"&gt;
          &lt;property name="userDAO" ref="UserDAO" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- User DAO Declaration --&gt;
      &lt;bean id="UserDAO" class="com.otv.user.dao.UserDAO"&gt;
          &lt;property name="sessionFactory" ref="SessionFactory" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>we have to defined all the classes in <code>application-context.xml</code> file differently(like i did above) or we can just use the below tag for each type of classes not a matter its DAO,Bean or Service?</p>
  
  <pre><code>&lt;context:component-scan base-package="com.forum.dao,com.forum.jsfbeans,com.forum.service" /&gt;
  </code></pre>
  
  <p>If we will defined something like above it will work and Spring know what action it have to perform in DAO,Service or Bean classes .</p>