我尝试向spring启动远程shell添加一个新的自定义命令,但没有成功。 在文档中只有一个可用的例子,但我喜欢使用Java创建一个新的命令。弹簧启动远程shell自定义命令
http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-remote-shell.html 我还要检查崩溃文档:http://www.crashub.org/1.3/reference.html#_java_commands
我把我的类包下的命令和crash.commands,但我没有看到我的新命令,如果我通过ssh和键入help连接到外壳。任何想法我做错了什么?
这是我的Java代码:
package commands;
import org.crsh.cli.Command;
import org.crsh.cli.Usage;
import org.crsh.command.BaseCommand;
import org.springframework.stereotype.Component;
@Component
public class hello extends BaseCommand {
@Command
@Usage("Say Hello")
public String test() {
return "HELLO";
}
}
Spring Boot shell扩展将命令视为Groovy脚本,而不是Spring bean。无论如何,您的Java代码通常可以用作Groovy;只需包含源代码,而不是编译的'.class'文件。 – chrylis 2014-10-05 10:00:12