快速解决
所需的凭证需要nexus定义的确切领域.请参阅下文,了解如何找到您定义的那个,但肯定是"Sonatype Nexus Repository Manager".正常情况下,将其余详细信息添加到凭据.
C:/data/user/.sbt/.credentials
realm=Sonatype Nexus Repository Manager
host=nexus
user=repouser
password=password
Run Code Online (Sandbox Code Playgroud)
build.sbt credentials + = Credentials(Path.userHome /".sbt"/".credentials")
publishTo <<= version { v: String =>
val nexus = "http://nexus/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/libs-snapshots")
else
Some("releases" at nexus + "content/repositories/libs-releases")
}
Run Code Online (Sandbox Code Playgroud)
问题
我正在尝试将jar发布到公司的nexus repo中.
我可以从Maven做到这一点,并且我已经配置了存储库以便能够使用Nexus提供内部jar.但是,由于授权,发布失败.
> publish
[info] Packaging c:\app\target\scala-2.10\app_2.10-0.1-sources.jar ...
[info] Wrote D:\app\target\scala-2.10\app_2.10-0.1.pom
[info] :: delivering :: com.app#app_2.10;0.1 :: 0.1 :: release :: Tue May 07 18:28:44 BST 2013
[info] Done packaging.
[info] delivering ivy file …Run Code Online (Sandbox Code Playgroud) scala> val a = List(1,2)
a: List[Int] = List(1, 2)
scala> val b = List(3,4)
b: List[Int] = List(3, 4)
scala> val c = List(5,6)
c: List[Int] = List(5, 6)
scala> val d = List(7,8)
d: List[Int] = List(7, 8)
scala> (a,b,c).zipped.toList
res6: List[(Int, Int, Int)] = List((1,3,5), (2,4,6))
Run Code Online (Sandbox Code Playgroud)
现在:
scala> (a,b,c,d).zipped.toList
<console>:12: error: value zipped is not a member of (List[Int], List[Int], List[Int], List[Int])
(a,b,c,d).zipped.toList
^
Run Code Online (Sandbox Code Playgroud)
我想做以下或类似的事情:
for((itemA,itemB,itemC,itemD) <- (something)) yield itemA + itemB …Run Code Online (Sandbox Code Playgroud) 虽然我只需按照主站点上的说明就可以在 Ubuntu 19.10 上运行无根 docker 容器,但它只持续了一天。
\n\nhttps://docs.docker.com/engine/security/rootless/
\n\n重启机器后,docker守护进程再也无法工作
\n\nsystemctl --user status docker\n\xe2\x97\x8f docker.service - Docker Application Container Engine (Rootless)\n Loaded: loaded (/home/ice/.config/systemd/user/docker.service; disabled; vendor preset: enabled)\n Active: failed (Result: exit-code) since Mon 2020-03-02 11:29:40 GMT; 2h 28min ago\n Docs: https://docs.docker.com\n Process: 1389 ExecStart=/home/ice/bin/dockerd-rootless.sh --experimental --storage-driver=overlay2 (code=exited, status=1/FAILURE)\n Main PID: 1389 (code=exited, status=1/FAILURE)\n\nMar 02 11:29:40 fractal systemd[8403]: docker.service: Service RestartSec=10s expired, scheduling restart.\nMar 02 11:29:40 fractal systemd[8403]: docker.service: Scheduled restart job, restart counter is at 3.\nMar 02 11:29:40 …Run Code Online (Sandbox Code Playgroud) 我为10,000,000个元素运行了一组性能基准测试,并且我发现每个实现的结果差别很大.
任何人都可以解释为什么创建一个Range.ByOne,导致性能优于简单的基元数组,但是将相同的范围转换为列表会导致比最坏的情况更糟糕的性能吗?
创建10,000,000个元素,并打印出1,000,000个模数的元素.JVM大小始终设置为相同的最小值和最大值:-Xms?m -Xmx?m
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit._
object LightAndFastRange extends App {
def chrono[A](f: => A, timeUnit: TimeUnit = MILLISECONDS): (A,Long) = {
val start = System.nanoTime()
val result: A = f
val end = System.nanoTime()
(result, timeUnit.convert(end-start, NANOSECONDS))
}
def millions(): List[Int] = (0 to 10000000).filter(_ % 1000000 == 0).toList
val results = chrono(millions())
results._1.foreach(x => println ("x: " + x))
println("Time: " + results._2);
}
Run Code Online (Sandbox Code Playgroud)
JVM大小为27m,需要141毫秒
相比之下,转换为List会显着影响性能:
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit._
object LargeLinkedList extends App {
def …Run Code Online (Sandbox Code Playgroud) 这个问题可能有点令人困惑,但目的是:
我想将值限制为类型参数的层次结构中的另一个值.鉴于它们都是类型,如果强制执行类似的代码,那将是很好的.
sealed trait Direction
case object Buy extends Direction
case object Sell extends Direction
case class Trade[D <: Direction](id: Long, itemId: Long, quantity: Int)
case class Hedge[D <: Direction, ??? -> O is D's OppositeDirection](id: Long, itemId: Long, openingTrade: Trade[D], closingTrade: Trade[O])
Run Code Online (Sandbox Code Playgroud)
简而言之:
val trade1 = Trade[Buy](id = 1, itemdId = 10, quantity = 100)
val trade2 = Trade[Sell](id = 2, itemdId = 10, quantity = -100)
val validHedge = Hedge[Buy, Sell](id = 563, itemId = 10, openingTrade= trade1, …Run Code Online (Sandbox Code Playgroud) 有没有更好/更短/更简洁的方式来写这个?
def elementOrNone[T](values: List[T], index: Int): Option[T] =
values match {
case Nil => None
case _ => Some(values(index))
}
Run Code Online (Sandbox Code Playgroud)