I have created a spring boot application to work spring batch framework.But unfornunately none of the RestController method is working:
My RestController class is as below
@RestController
@RequestMapping(path = "/myapp")
public class MyBatchController {
@Autowired
private JobLauncher jobLauncher;
@Autowired
@Qualifier("myJob")
private Job myJob;
@PostMapping(value = "/invokeMyJob")
@CrossOrigin
public ResponseEntity<String> processStock(){
JobExecution myJobExecution = null;
ResponseEntity<String> myJobResponse = null;
JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis())
.toJobParameters();
try {
myJobExecution = jobLauncher.run(myJob, jobParameters);
myJobResponse = new ResponseEntity<String>(myJobExecution.getExitStatus().getExitCode(), HttpStatus.OK);
}catch(Exception e) {
e.printStackTrace();
myJobResponse = new ResponseEntity<String>("failure", HttpStatus.INTERNAL_SERVER_ERROR);
}
return myJobResponse;
}
}
PFB my postman response
My Main application class is as below:
@SpringBootApplication
@ComponentScan(basePackages = "{com.myapp.batch}")
public class MybatchApplication {
public static void main(String[] args) {
SpringApplication.run(MybatchApplication.class, args);
}
}
I am not able to track why I am getting 404 in postman???
