title: How can I call beans in spring mvc controller method .
body: <p>I have the QuartzConfig configuration class that have three beans ,How can I call this beans in spring mvc controller method.  </p>
  
  <p>This beans executed automatically once I start application,But I don't want that I want to execute this beans by controller</p>
  
  <p>Quartz configuration class     </p>
  
  <pre><code>@Configuration
  public class QuartzConfig {
  
  @Autowired
  private PlatformTransactionManager transactionManager;
  
  @Autowired
  private ApplicationContext applicationContext;
  
  @Bean
  public SchedulerFactoryBean quartzScheduler() {
      SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean();
  
      quartzScheduler.setTransactionManager(transactionManager);
      quartzScheduler.setOverwriteExistingJobs(true);
  
      AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
      jobFactory.setApplicationContext(applicationContext);
      quartzScheduler.setJobFactory(jobFactory);
  
      Trigger[] triggers = {
              processMyJobTrigger().getObject()
      };
  
      quartzScheduler.setTriggers(triggers);
  
      return quartzScheduler;
  }
  
  @Bean
  public JobDetailFactoryBean processMyJob() {
      JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
      jobDetailFactory.setJobClass(HelloJob.class);
      jobDetailFactory.setDurability(true);
      return jobDetailFactory;
  }
  
  @Bean
  public CronTriggerFactoryBean processMyJobTrigger() {
      CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
      cronTriggerFactoryBean.setJobDetail(processMyJob().getObject());
      cronTriggerFactoryBean.setCronExpression("0 0/1 * * * ?");
      return cronTriggerFactoryBean;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Quartz job</p>
  
  <pre><code>@Service
  @Transactional
  public class HelloJob implements Job{
  
  @Inject
  TestrecordRepository testrecordRepository;
  @Inject
  ScoreRepository scoreRepository;
  
  
  public void execute(JobExecutionContext context)
          throws JobExecutionException {
              System.out.println("Hello Quartz!");    
              List&lt;Testrecord&gt; records=testrecordRepository.findAll();
              for(Testrecord t:records){
                  Testrecord testrecord = new Testrecord();
                  testrecord.setValue_integer(t.getValue_integer());
                  testrecord.setId(t.getId());
                  RuleExecutor ruleExecutor = new RuleExecutor();
                  Score score= ruleExecutor.processRules(testrecord);
                  scoreRepository.save(score);    
              }
  
          }
  </code></pre>
  
  <p>}</p>