title: Get bean with specific Arguments to constructor in Spring
body: <p>assume I have that class</p>
  
  <pre><code>public Student{
   private String name;
   private Address address;
  
   public Student(String fName, Address address){
    name = fname;
    this.address = address;
  }
  </code></pre>
  
  <p>I defined this class within Spring configuration as </p>
  
  <pre><code> &lt;bean name="studentInstance" class="StackOverFlow.Student"/&gt;
  </code></pre>
  
  <p>now i'd like to use getBean with parameter I will pass to constructor.
  equal to <code>Student s = new Student(name,address)</code>
  I know Spring supplies a methond getBean(class_name,parms....)
  however I dont know how I should  config Spring.xml configuration file.
  I would like to avoid using Setter and getter in order to fill a new bean.</p>
  
  <p>I found lots of example of how to define <code>&lt;/constructor-arg&gt;</code> within the xml but each time it was with default values. here I let the user to enter different values for each object.
  I'd like to use <code>
  ApplicationContext context = new ClassPathXmlApplicationContext(Spring.xml file path);
  Student s= (Student)context.getBean("studentInstance",name,address);</code></p>
  
  <p><strong>I need help with the configuration file only</strong></p>
  
  <p><strong>Thanks in Advance!!</strong></p>
  
  <p>I already checked those links :
  <a href="https://stackoverflow.com/questions/6784960/spring-and-passing-parameters-to-factory-method-in-runtime">Link1</a> <a href="http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/context/support/AbstractApplicationContext.html#getBean%28java.lang.String,%20java.lang.Object...%29" rel="nofollow noreferrer">Link2</a> <a href="http://docs.spring.io/spring/docs/2.5.3/reference/beans.html#beans-factory-collaborators" rel="nofollow noreferrer">Link3</a> <a href="https://stackoverflow.com/questions/21829162/spring-bean-instantiation-by-passing-constructor-args">Link4</a></p>
  
  <p>~~~~~Edit ~~~~~~~</p>
  
  <p>Solved! constructor-injection is not needed here
  I just added prototype  scope to my bean as shown below.</p>
  
  <pre><code>&lt;bean name="carInstance" class="MainApp.bl.GasStation.Car" scope="prototype"/&gt;
  </code></pre>