Search code examples
javaspringspring-bootcommand-line-interfacespring-shell

Spring Shell - usage and execution


I want to integrate Spring Shell within a spring boot application. I am able to execute the examples from the official git-repo. But when migrating the example code to my own project that is very very similar to this code, my individual shell is not shown or usable. Instead the default Spring Shell splash is shown is usable:

<SpringShell ASCII-Art>
1.1.0.RELEASE

Welcome to Spring Shell. For assistance press or type "hint" then hit ENTER
spring-shell>

Compilation gives no errors, but the individual sample @component marked classes are not used. All annotations are properly set. A standard loader outside is existent. I am not executing the code in an IDE.

Although the documentation (chapter 3.5) tells, that the components are automatically collected as far as i understood.

So my question is more or less how to setup the usage better than this:

public class Main {
    public static void main(String[] args) throws Exception {
        Bootstrap.main(args);
    }
}

And to defeat the default splash!


Solution

  • That comment in the documentation is a bit misleading (I'll change it). For your components to be picked up, they need to be on the classpath AND you'll need to scan for them somehow.

    See for example how in the Spring XD project, there is a scan for the org.springframework.xd.shell package. You need to do something similar for your own package.