title: Spring dynamic parameter injection
body: <p>I am trying to get my head around the autowiring concept, but I am facing the problem of a bean with a dependency that needs an int in the constructor but I dunno how to provide it dynamically without putting a static value in the config.</p>
  
  <p>Main Class:</p>
  
  <pre><code>@SpringBootApplication
  
  public class BootDemoApplication {
  
      public static void main(String[] args) {
          ApplicationContext applicationContext = SpringApplication.run(BootDemoApplication.class, args);
          Account account = applicationContext.getBean(Account.class, 231);
      }
  }
  </code></pre>
  
  <p>Bean:</p>
  
  <pre><code>@Component
  public class Account {
  
      @Autowired
      Salary salary;
  
      @PostConstruct
      public void init() {
          System.out.println(salary.getSalary());
      }
  
  }
  </code></pre>
  
  <p>Dependency:</p>
  
  <pre><code>@Component
  public class Salary {
  
      private int salary;
  
      public Salary(int salary) {
          this.salary = salary;
      }
  
      public int getSalary() {
          return salary;
      }
  
  }
  </code></pre>
  
  <p>The error that I get is:</p>
  
  <pre><code>Parameter 0 of constructor in io.cptpackage.springboot.bootdemo.account.Salary required a bean of type 'int' that could not be found.
  
  Action:
  Consider defining a bean of type 'int' in your configuration.
  </code></pre>