Search code examples
javatomcatspring-shell

Using Spring Shell with Tomcat


As described here:

https://github.com/indrabasak/spring-shell-example

most of spring shell projects are launched by this way:

mvn clean install

then

java -jar target/[generated_jar]jar

Now, every time a user need to use the console generated by the spring shell project he needs to run the jar and load the entire application.

With Tomcat, is it possible to start the application only once and expose it, by a command line for example, for anyone who want to access to the shell terminal?


Solution

  • Spring Shell is different than Spring MVC or Spring Boot, it is not a server to run and accept continuous incoming request. Think of it as a command line where you can open it when you need it and close it after you are done.

    It is possible to open the shell and not close it. You need to use the screen command -> https://linuxize.com/post/how-to-use-linux-screen/ Just reattach to the screen when needed, instead of creating a new shell instance.