0

我正在尝试使用spring-shell。创建了这样的类:

@Component
public class T implements CommandMarker {

public T() {
    System.out.println("T Constructor");
}

@CliCommand(value = "trans", help = "translate")
public String translate(@CliOption(key = { "msg" }, 
    mandatory = false, help = "The hello world message")
    final String msg) {
    System.out.println("!!! " + msg);
    return "!!! " + msg;
  }
}

并拥有这样的 spring-shell-plugin.xml

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.1.xsd">   

   <context:component-scan base-package="com" /> 

</beans>

启动应用程序的类:

public class Main {

public static void main(String[] args) {
    ClassPathXmlApplicationContext context =
            new ClassPathXmlApplicationContext("classpath*:/META-INF/spring/spring-shell-plugin.xml");
    context.start();
}
}

但结果我只是进入控制台'T构造函数'虽然我正在传递参数'trans --msg f'。

如何使它起作用?

4

1 回答 1

0
public static void main(String[] args) throws IOException {
    Bootstrap.main(args);
}
于 2017-03-29T15:54:34.947 回答