title: Spring Bean and @Autowired constructor with params
body: <p>I would like to understand if is possible to use and how can I do to do a Bean with a @Autowired Constructor and params.</p>
  
  <pre><code>@Component
  public class Routes
  {
      private Foo req;
  
      @Autowired
      public Routes(Foo req)
      {
          this.req = req;
      }
      public String getUrl(String destin)
      {
          return req.getContextPath() + destin;
      }
  }
  
  @Component
  public class HomeController
  {
      @Autowired
      private Routes routes;
  
      public HomeController(Foo req)
      {
          String foo = routes.getUrl("something");
      }
  }
  </code></pre>
  
  <p>REAL CODE ------EDITING---------------
  The exception is happening on the line:
  String foo = rt.getUrl("caca");</p>
  
  <pre><code>public class AppRun extends HttpServlet {
  
      private static final long serialVersionUID = -3308874705513248491L;
  
      private ApplicationContext context;
  
      @Override
      public void service(HttpServletRequest req, HttpServletResponse resp)
              throws ServletException, IOException
      {
          context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
  
          FooTest ft = new FooTest();
  
          HomeControllerTest hc = (HomeControllerTest) context.getBean("homeControllerTest", new Object[]{ft});
      }
  }
  
  @Component
  @Scope("prototype")
  public class FooTest {
  
      public String mensagem()
      {
          System.out.println("funcionou");
          return "ok";
      }
  
  }
  
  @Component
  @Scope("prototype")
  public class RoutesTest {
  
      private FooTest req;
  
      @Autowired
      public RoutesTest(FooTest req)
      {
          this.req = req;
      }
  
      public String getUrl(String destin)
      {
          return req.mensagem().concat(destin);
      }
  
  }
  
  @Component
  @Scope("prototype")
  public class HomeControllerTest {
  
      @Autowired
      private RoutesTest rt;
  
      public HomeControllerTest(FooTest req)
      {
          String foo = rt.getUrl("caca");
  
          System.out.println(foo);
      }
  
  }
  </code></pre>