Run project with java options via sbt

眉间皱痕 提交于 2019-12-22 03:58:59

问题


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.




回答3:


Have a look at one of my project where I pass in command line arguments via sbt:

https://github.com/joesan/plant-simulator/blob/master/README.md

I guess your double quotes is messing it up! Try it without them!



来源:https://stackoverflow.com/questions/47889564/run-project-with-java-options-via-sbt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!