How to Create a Command for Spring Shell

1) Create the command class:

package br.eti.fernandoribeiro.sample;

import org.springframework.stereotype.Component;

public final class SampleCommands implements CommandMarker {

  @CliCommand(value = "sample do-something", help = "Does something")
  public void doSomething() {


2) Create the META-INF/spring/spring-shell-plugin.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="" xmlns:xsi="" xmlns:context="" xsi:schemaLocation="">
  <context:component-scan base-package="br.eti.fernandoribeiro.sample" />

3) Build the archive.

4) Drop the archive in the class path.

5) Run the command:

$ sample do-something

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s