-->

Run project with java options via sbt

2020-08-22 07:20发布

问题:

I am running my fat jar with command java -Djava.security.krb5.conf=/krb5.conf -jar my.jar.

How to run my app with this option via sbt?
$ sbt -Djava.security.krb5.conf="module\\src\\main\\resources\\krb5.conf" run doesn't work. Error:

ctl-scala>sbt -Djava.security.krb5.conf="ctl-core\src\main\resources\krb5.conf" ctl-ui-backend/run
Warning: invalid system property 'java.security.krb5.conf'
[info] Loading global plugins from C:\Users\User\.sbt\0.13\plugins
[info] Loading project definition from C:\Users\User\IdeaProjects\ctl-scala\project
[info] Set current project to ctl (in build file:/C:/Users/User/IdeaProjects/ctl-scala/)
[error] No valid parser available.
[error] ctl-core\\src\\main\\resources\\krb5.conf
[error]             ^

回答1:

Can you try sbt -J-Djava.security.krb5.conf="module/src/main/resources/krb5.conf" run

The -J causes the sbt launcher to pass those as options to the JVM.



回答2:

As sbt manual it will pass JAVA_OPTS environment variable to the java and if you can not set the variable .jvmopts will hold the java commandline arguments. so if you are in bash :

export JAVA_OPTS="-Djava.security.krb5.conf=/krb5.conf"

before sbt command will pass the argument to java runtime.



标签: scala sbt