简体   繁体   中英

Could not find or load main class while passing class a argument spring batch job

public class demoRunner extends CommandLineJobRunner {
    public static void main(String[] args) throws Exception {
        // initialize fileappender here
        String logFile = args[args.length - 1].split("=")[1];
        DemoAppender.initializeAppender(logFile);
        CommandLineJobRunner.main(args);
    }
}

Run As VM argument : META-INF/spring/student.xml student

student is a job

Location of demoRunner.java : demoBatchJob\src\main\java\com\ncs\sma\runner\demoRunner.java

Location of stduent.xml : demoBatchJob\src\main\resources\META-INF\spring\student.xml

Exception:

Error: Could not find or load main class META-INF.spring.student.xml Caused by: java.lang.ClassNotFoundException: META-INF.spring.student.xml

Try putting it outside META-INF and add the below VM argument -

spring/student.xml

Run As VM argument: META-INF/spring/student.xml student

You need to select demoRunner as the main class to run and pass the input file and job name META-INF/spring/student.xml student as "Program argument" and not as "VM argument".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM