Commit 49994936 authored by YuCheng Hu's avatar YuCheng Hu

Spring boot command project

parent c567e7c6
Pipeline #47 failed with stages
package us.cwiki.spring.boot.command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.Arrays;
@SpringBootApplication
public class Application implements ApplicationRunner {
private static final Logger logger = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
@Override
public void run(ApplicationArguments args) throws Exception {
logger.info("Application started with command-line arguments: {}", Arrays.toString(args.getSourceArgs()));
logger.info("NonOptionArgs: {}", args.getNonOptionArgs());
logger.info("OptionNames: {}", args.getOptionNames());
for (String name : args.getOptionNames()) {
logger.info("arg-" + name + "=" + args.getOptionValues(name));
}
boolean containsOption = args.containsOption("person.name");
logger.info("Contains person.name: " + containsOption);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment