From 537849923c117a0f6625d9871a6cc7bf64de6c81 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Tue, 3 Mar 2015 22:35:27 +0800 Subject: [PATCH] Update and rename 43.2.1. Remote shell commands to 43.2.1. Remote shell commands.md --- .../43.2.1. Remote shell commands | 0 .../43.2.1. Remote shell commands.md | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+) delete mode 100644 V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands create mode 100644 V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands.md diff --git a/V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands b/V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands deleted file mode 100644 index e69de29..0000000 diff --git a/V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands.md b/V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands.md new file mode 100644 index 0000000..b23b3c5 --- /dev/null +++ b/V. Spring Boot Actuator: Production-ready features/43.2.1. Remote shell commands.md @@ -0,0 +1,33 @@ +### 43.2.1. 远程shell命令 + +你可以使用Groovy或Java编写其他的shell命令(具体参考CRaSH文档)。默认情况下,Spring Boot会搜索以下路径的命令: +* `classpath*:/commands/**` +* `classpath*:/crash/commands/**` + +**注**:可以通过`shell.commandPathPatterns`属性改变搜索路径。 + +下面是一个从`src/main/resources/commands/hello.groovy`加载的'hello world'命令: +```java +package commands + +import org.crsh.cli.Usage +import org.crsh.cli.Command + +class hello { + + @Usage("Say Hello") + @Command + def main(InvocationContext context) { + return "Hello" + } + +} +``` +Spring Boot将一些额外属性添加到了InvocationContext,你可以在命令中访问它们: + +|属性名称|描述| +|------|:------| +|spring.boot.version|Spring Boot的版本| +|spring.version|Spring框架的核心版本| +|spring.beanfactory|获取Spring的BeanFactory| +|spring.environment|获取Spring的Environment|