I am trying to create a batch job using ApplicationRunner in my sprinbootApplication and I want to use the command line arguments as variables in my code. So i want to extract the command line arguments, make beans from them and use them in my code. How to achieve it ?
@SpringBootApplication
public class MySbApp implements ApplicationRunner {
public static void main(String[] args) {
SpringApplication.run(Myclass.class, args);
}
@Autowired
private Myclass myclass;
@Override
public void run(ApplicationArguments args) throws Exception {
String[] arguments = args.getSourceArgs();
for (String arg : arguments) {
System.out.println("HEYYYYYY" + arg);
}
Myclass.someMethod();
}
}
How do I create beans here ?