【问题标题】:Execute a command programmatically in Spring Boot app在 Spring Boot 应用程序中以编程方式执行命令
【发布时间】:2020-07-20 08:02:20
【问题描述】:

我想在 SpringBoot 应用程序中执行这个命令:

keytool -import -keystore trustStore.jks -file certCA.der -storepass example << EOF
\ yes
\ EOF

我的问题是我无法在我的代码中自动插入“是”。

Runtime.getRuntime().exec("keytool -import -keystore trustStore.jks -file certCA.der -storepass example");

我该怎么做?

【问题讨论】:

    标签: spring-boot command-line-arguments keytool


    【解决方案1】:

    在您的命令中使用 -noprompt 参数

    【讨论】:

    • 感谢您的回答。我尝试在命令中添加 -noprompt 参数,但从服务日志看来,该参数不信任信任(就好像它对提示中的问题回答否)。事实上,我有这个异常:原因:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径
    猜你喜欢
    • 2017-02-24
    • 2014-05-21
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-14
    • 2020-12-06
    • 2016-03-24
    相关资源
    最近更新 更多