Is it possible to read console input just before the embedded tomcat on the spring boot starts? The supposedly application flow is, request username and password from the user,
You can use nohup to start the jar with the parameters, they just won't be prompted for them on new lines in the terminal. The User could add them as parameters when starting the jar. See details below.
Example:
Main Class
public static void main(String[] args) {
String username = args[0];
String password = args[1];
if(username.equals("admin") && password.equals("password")) {
SpringApplication.run(NohupApplication.class, args);
} else {
System.out.println("You are not authorized to start this application.");
}
}
With Invalid Credentials
Command
nohup java -jar example.jar user password
nohup.out
You are not authorized to start this application.
With Valid Credentials
Command
nohup java -jar example.jar admin password
nohup.out
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)