我正在用命令运行胖子罐java -Djava.security.krb5.conf=/krb5.conf -jar my.jar。
如何通过sbt使用此选项运行我的应用程序?
$ sbt -Djava.security.krb5.conf="module\\src\\main\\resources\\krb5.conf" run不起作用。错误:
ctl-scala> sbt -Djava.security.krb5.conf =“ ctl-core \ src \ main \ resources \ krb5.conf” ctl-ui-backend / run
警告:无效的系统属性'java.security.krb5.conf'
[info]从C:\ Users \ User \ .sbt \ 0.13 \ plugins加载全局插件
[info]从C:\ Users \ User \ IdeaProjects \ ctl-scala \ project加载项目定义
[info]将当前项目设置为ctl(在构建文件中:/ C:/ Users / User / IdeaProjects / ctl-scala /)
[错误]没有有效的解析器。
[错误] ctl-core \\ src \\ main \\ resources \\ krb5.conf
[错误] ^
我有一个json复杂的结构。像这样的东西:
{
"a":"aa",
"b":"bb",
"c":[
"aaa",
"bbb"
],
"d":{
"e":"ee",
"f":"ff"
}
}
Run Code Online (Sandbox Code Playgroud)
我想大写所有字符串值。文档说:
root.each.string.modify(_.toUpperCase)
Run Code Online (Sandbox Code Playgroud)
但正如预期的那样,只更新了根值。
如何circe-optics递归遍历所有字符串值?
JSON结构事先未知。
这是关于 Scastie的例子。
通过评论:我希望所有字符串值都大写,而不仅仅是根值:
{
"a":"AA",
"b":"BB",
"c":[
"AAA",
"BBB"
],
"d":{
"e":"EE",
"f":"FF"
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个简单的任务:
lazy val myCustomTask = TaskKey[Unit]("description of my task")
myCustomTask := {
val arg = "arg1" // Not used yet
(runMain in Compile).toTask(" com.company.Main").value
}
Run Code Online (Sandbox Code Playgroud)
效果很好。
但我需要传递一些论点。如果我这样做:
(runMain in Compile).toTask(s" com.company.Main $arg").value
Run Code Online (Sandbox Code Playgroud)
我收到错误:
错误:非法动态引用:arg
(runMain in Compile).toTask(s" com.company.Main $arg").value
^
[error] 表达式中的类型错误
如何正确传递参数?
PS抱歉我的英语,这不是我的母语。
我需要将字符串保存到文本文件并发送到浏览器.我的路线:
def genFileRoute: Route =
path("someresource" / "generate") {
get {
complete( genFile )
}
}
Run Code Online (Sandbox Code Playgroud)
但我有发电机的问题:
def genFile = {
val str = "Hi all! I am a string in future text file"
// Need to write some code here :(
// Something like 'php://output' with headers, but for akka.
}
Run Code Online (Sandbox Code Playgroud)
如何在file.txt不使用文件系统的情况下创建内存中的文本文件?如何将其发送到客户端浏览器(下载)?
PS对不起我的英文,这不是我的母语.
我正在尝试在测试中使用私有 trait 字段。非常简单的例子:
//Works fine with class A, but not trait A
trait A {
private val foo = "Some string"
}
class Test extends A {
val field = classOf[A].getDeclaredField("foo")
field.setAccessible(true)
val str = field.get(this).asInstanceOf[String]
}
Run Code Online (Sandbox Code Playgroud)
我有:
java.lang.NoSuchFieldException: foo 在 java.lang.Class.getDeclaredField
现场示例在这里
如何让这个片段可执行?
我通过 Scala 在 Scala 上使用 GraphQL Sangria。我也正在使用apollo-codegen.
我想定义一次架构,因此我通过以下方式将架构从后端导出到前端:
schema.renderPretty
Run Code Online (Sandbox Code Playgroud)
问题在于桑格利亚汽酒的renderPretty打印模式格式schemaAst。但apollo-codegen需要json格式。
如何制作sangriajson格式的渲染模式?或者也许可以轻松转换schemaAst为jsonvia SBT?
例如我有一组查询:
for {
entity <- sql"<select some optional entity from db>".query[Entity].option
result <- sql"<insert some data using entity>".update.run
} yield result
Run Code Online (Sandbox Code Playgroud)
当找不到实体并引发错误“实体不存在”时,如何不插入一些数据?
就像是:
for {
entity <- sql"<select some optional entity from db>".query[Entity].option
result <- entity // Option[Entity]
.fold(ConnectionIO.raiseError("entity does not exists")) // ConnectionIO.raiseError does not compile
(e => sql"<insert some data using entity>".update.run)
} yield result
Run Code Online (Sandbox Code Playgroud) 例如,我有两个Try对象.如果一个或另一个失败并以相同的方式处理它,我想得到错误:
val t1 = Try(throw new Exception("one"))
val t2 = Try(throw new Exception("two"))
(t1, t2) match {
case (Success(_), Success(_)) => println("It's ok")
case _ : Failure(e), _) | (_, Failure(e) => // Compile error here
println("Fail", e) // Doesn't matter from where e was come
}
Run Code Online (Sandbox Code Playgroud)
是否可以e在两个失败选项编译中使用相同的代码?