title: how to use @Service annotation in Spring MVC to create the bean of Service layer
body: <p>Can someone tell how to get the bean of service layer in spring MVC. One way to get the bean of service layer is by using @Service annotation but how to do that, I don't know.
  Controller:</p>
  
  <pre><code>@Controller
  public class ConfigureApplicationController {
  
      @RequestMapping(value="/ConfigureApplication.html", method=RequestMethod.GET)
      public ModelAndView getListOfAllConfigureApplication(){
  
          AppConfigureServiceImpl getService=new AppConfigureServiceImpl();
  
          ArrayList&lt;ConfigureApplication&gt; results =getService.getListOfAllAppConfigure();
          ModelAndView model=new ModelAndView("ConfigureApplication");
          model.addObject("results",results);
          return model;
      }
  </code></pre>
  
  <p>and serviceImpl is:</p>
  
  <pre><code>@Service("appConfigureServiceImpl")
  public class AppConfigureServiceImpl implements AppConfigureService {
  
      public ArrayList&lt;ConfigureApplication&gt; getListOfAllAppConfigure(){
  
          @SuppressWarnings("resource")
          ApplicationContext ctx=new ClassPathXmlApplicationContext("spring-dispatcher-servlet.xml");
          AppConfigureDAOImpl getAll=ctx.getBean("appConfigureDAOImpl", AppConfigureDAOImpl.class);
  
          ArrayList&lt;ConfigureApplication&gt; results =getAll.getList();
          return results;
      }
  </code></pre>
  
  <p>In this i have made the object of AppConfigureServiceImpl (in service layer)then i invoke the method but by doing so i am not using dependency injection in spring. I know i can do this using @Service annotation but i don';t know the syntax. can someone help me to solve this problem.</p>