0

My spring boot 2.x application is a servlet server. It needs to perform actions based on command line args only one of which is starting the servlet server.

Here's the example:

@SpringBootApplication
public class ExampleMain implements CommandLineRunner {

    public static void main(String[] args) {
        new SpringApplicationBuilder(ExampleMain.class)
                                    .web(WebApplicationType.NONE)
                                    .run(args);
    }
    @Override
    public void run(String... args) throws Exception {
        if (args[0].equals("help")) {
            System.out.println("Help is on the way");
        } else if (args[0].equals("start")) {
            // START Servlet Server here
        }
    }

}

I'm guessing there is some injectable instance I can use to start the servlet server, but I don't have a clue where to find it.

Mike Cooper
  • 1,065
  • 3
  • 13
  • 34

1 Answers1

0

If providing a command-line argument is the main reason you are thinking about using some command-line runner. I can provide you with the following solution-

You can provide command-line arguments from IntelliJ/Netbeans IDE itself. For IntelliJ, you can see this discussion

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 1
    "Please upvote my answer if this solution was helpful"—don't beg for upvotes. Users can vote (or not vote) however they wish. – ChrisGPT was on strike Mar 01 '22 at 00:30
  • Thanks but I'm not looking for something related to IDEs. My deployed application needs to be able to perform different operations based on command line args – Mike Cooper Mar 01 '22 at 05:54