Add Application for Spring to Run

This commit is contained in:
YuCheng Hu 2022-08-11 12:55:47 -04:00
parent eb1f958e06
commit 696d1f31bb
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package com.usvisatrack.services;
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) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(ApplicationArguments args) {
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);
}
}