如何将配置文件传递给maven (3.0.5)
中的scala程序?
以下似乎不起作用。使用scala-maven-plugin (3.1.6)
。
mvn clean compile scala:run -DmainClass=org.mitchus.myprog.MyMain -Dconfig.file=my.conf
[...]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
Caused by: java.lang.ExceptionInInitializerError
at org.mitchus.myprog.MyMain.main(MyMain.scala)
... 6 more
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'mykey'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:145)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:151)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164)
at com.typesafe.config.impl.SimpleConfig.getObject(SimpleConfig.java:218)
at com.typesafe.config.impl.SimpleConfig.getConfig(SimpleConfig.java:224)
at com.typesafe.config.impl.SimpleConfig.getConfig(SimpleConfig.java:33)
at com.github.kxbmap.configs.ConfigsInstances$$anonfun$configsAtPath$1.apply(Configs.scala:74)
at com.github.kxbmap.configs.ConfigsInstances$$anonfun$configsAtPath$1.apply(Configs.scala:74)
at com.github.kxbmap.configs.Configs$$anonfun$atPath$1$$anonfun$apply$1.apply(Configs.scala:43)
at com.github.kxbmap.configs.Configs$$anonfun$atPath$1$$anonfun$apply$1.apply(Configs.scala:43)
at com.github.kxbmap.configs.package$EnrichTypesafeConfig$.get$extension(package.scala:36)
at org.mitchus.myprog.ConfigLoading$class.$init$(ConfigLoading.scala:24)
at org.mitchus.myprog.MyMain$.<init>(MyMain.scala:16)
at org.mitchus.myprog.MyMain$.<clinit>(MyMain.scala)
... 7 more
答案 0 :(得分:0)
尝试将-Dconfig.file
添加到插件的jvmArgs
属性中。