sbt 程序集无法创建 jar 获取 java.lang.UnsupportedOperationException

sbt assembly cannot create jar getting java.lang.UnsupportedOperationException

我正在使用

scala 1.12.10
akka 2.6.3
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")

但是当执行 sbt assembly 我得到:

java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
    at java.base/java.lang.System.setSecurityManager(System.java:416)
    at sbt.TrapExit$.installManager(TrapExit.scala:53)
    at sbt.StandardMain$.runManaged(Main.scala:109)
    at sbt.xMain.run(Main.scala:76)
    at xsbt.boot.Launch$$anonfun$run.apply(Launch.scala:111)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:131)
    at xsbt.boot.Launch$.run(Launch.scala:111)
    at xsbt.boot.Launch$$anonfun$apply.apply(Launch.scala:37)
    at xsbt.boot.Launch$.launch(Launch.scala:120)
    at xsbt.boot.Launch$.apply(Launch.scala:20)
    at xsbt.boot.Boot$.runImpl(Boot.scala:56)
    at xsbt.boot.Boot$.main(Boot.scala:18)
    at xsbt.boot.Boot.main(Boot.scala)

[错误] [launcher] sbt 启动器错误:java.lang.UnsupportedOperationException:安全管理器已弃用,将在未来版本中删除

运行 java 18

java -version
openjdk version "18" 2022-03-22
OpenJDK Runtime Environment (build 18+36-2087)
OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing)

它已被弃用并在 17 年被删除,因此在 18 年它预计不会工作 参考:https://openjdk.java.net/jeps/411 你能试试吗

System.setSecurityManager(null)

学分:

使用 java 8 按照 Animal 的建议解决此问题