run spring batch job from the controller

You can launch a batch job programmatically using JobLauncher which can be injected into your controller. See the Spring Batch documentation for more details, including this example controller:

@Controller
public class JobLauncherController {

    @Autowired
    JobLauncher jobLauncher;

    @Autowired
    Job job;

    @RequestMapping("/jobLauncher.html")
    public void handle() throws Exception{
        jobLauncher.run(job, new JobParameters());
    }
}

You need to create a application.yml file in the src/main/resources and add following configuration:

spring.batch.job.enabled: false

With this change, the batch job will not automatically execute with the start of Spring Boot. And batch job will be triggered when specific link.

Check out my sample code here: https://github.com/pauldeng/aws-elastic-beanstalk-worker-spring-boot-spring-batch-template