感谢@AndyWilkinson增强报告,
ApplicationRunner在Spring Boot
1.3.0中添加了接口(目前仍在Milestones中,但我希望很快会发布)
这里是使用它和解决问题的方法:
@Componentpublic class FileProcessingCommandLine implements ApplicationRunner { @Override public void run(ApplicationArguments applicationArguments) throws Exception { for (String filename : applicationArguments.getNonOptionArgs()) File file = new File(filename);service.doSomething(file); } }}


