如何在命令行上为 runMain 设置系统属性? [英] How to set system properties for runMain on command line?

查看:34
本文介绍了如何在命令行上为 runMain 设置系统属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Windows 的命令行中为 runMain 设置系统属性?

How can I set a system property for runMain upon executing it from command line on Windows?

我希望能够运行以下命令:

I'd like to be able to run the following command:

sbt -Dconfig.resource=../application.conf "runMain akka.Main com.my.main.Actor"

不管fork是不是真的,是我把它放在SBT_OPTS里,还是我怎么传入的,我都做不到.我熟悉 在构建中未定义默认值时在命令行上设置设置值?使用sbt run"设置系统属性,但都没有回答我的问题.

Regardless of whether fork is true, whether I put it in SBT_OPTS, or how I pass it in I cannot accomplish this. I am familiar with both Setting value of setting on command line when no default value defined in build? and Setting system properties with "sbt run" but neither answer my question.

其他问题似乎表明您甚至无法在 SBT 中轻松查看 Java 调用参数.任何帮助表示赞赏.

Other questions seem to indicate you can't even easily view the Java invocation arguments easily in SBT. Any help is appreciated.

推荐答案

这有效:

sbt '; set javaOptions += "-Dconfig.resource=../application.conf" ; runMain akka.Main com.my.main.Actor'

如果这不是一个足够友好"的语法,请将其包装在一个小的 shell 脚本中.

If this isn't a "friendly" enough syntax, wrap it in a little shell script.

(请注意,这假设您已将 fork 设置为 true 以运行.如果没有,请参阅 akauppi 的评论.)

(Note this assumes you have fork set to true for running. If you don't, see akauppi's comment.)

这篇关于如何在命令行上为 runMain 设置系统属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆