title: Get bean of @Service annotated class?
body: <p>In my web application, I am not using <code>applicationContext.xml</code>. How can I get the bean of <code>@Service</code> annotated class?</p>
  
  <p>If I used the <code>applicationContext.xml</code> in my web application, I have to load the <code>applicationContext.xml</code> every time to get the bean of the <code>@Service</code> annotated class.</p>
  
  <p>I used this way</p>
  
  <pre><code>WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext);
  ServerConnection  con = (ServerConnection ) ctx.getBean("con");
  </code></pre>
  
  <p>My Service class will be as ,</p>
  
  <pre><code>@Service  or @Service("con")
  public class ServerConnection {
  
      private  TServerProtocol tServerProtocol;
      private  URI uri;
  
      public TServerProtocol getServerConnection(){
  
          System.out.println("host :"+host+"\nport :"+port);
  
          try {
              uri = new URI("tcp://" + host + ":" + port);
          } catch (URISyntaxException e) {
              System.out.println("Exception in xreating URI Path");
          }
  
          tServerProtocol = new TServerProtocol(new Endpoint(uri));
          return tServerProtocol;
      }
  }
  </code></pre>
  
  <p>Is there <em>any other way to get a bean</em> of this class ? </p>
  
  <p>or</p>
  
  <p>What is the proper way to get a bean of <code>@Service</code> annotated class in case of core application and web application in Spring3.x?</p>