该版本仍在开发中,尚未被视为稳定。最新稳定版本请使用Spring Shell 3.4.1spring-doc.cadn.net.cn

验证

Spring Shell 与 Bean Validation API 集成以支持 对命令参数的自动和自文档约束。spring-doc.cadn.net.cn

命令参数上的注释和方法层的注释有 执行命令前,执行 HONORED 并触发验证。请考虑以下命令:spring-doc.cadn.net.cn

	@ShellMethod("Change password.")
	public String changePassword(@Size(min = 8, max = 40) String password) {
		return "Password successfully set to " + password;
	}

从前面的例子来看,你可以免费获得以下行为:spring-doc.cadn.net.cn

shell:>change-password hello
The following constraints were not met:
	--password : size must be between 8 and 40 (You passed 'hello')