我通过终端使用以下命令安装SBT:
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt
在我的Ubuntu 18.04和java版本上:
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
安装成功但是当我尝试通过终端启动SBT
时,我已经
https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/1.1.6/ivys/ivy.xml
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.scala-sbt#sbt;1.1.6: not found
::::::::::::::::::::::::::::::::::::::::::::::
:::: ERRORS
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.1.6/sbt-1.1.6.pom
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.1.6/sbt-1.1.6.jar
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt/1.1.6/sbt-1.1.6.pom
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt/1.1.6/sbt-1.1.6.jar
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt/1.1.6/sbt-1.1.6.pom
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt/1.1.6/sbt-1.1.6.jar
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/1.1.6/ivys/ivy.xml
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/1.1.6/ivys/ivy.xml
有什么问题?
更新
developer@monad:~$ sudo apt-get purge openjdk-8-jdk java-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
openjdk-11-jre-headless : Depends: ca-certificates-java but it is not going to be installed
Depends: java-common (>= 0.28) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
已安装的java版本列表:
developer@monad:~$ update-java-alternatives --list
java-1.11.0-openjdk-amd64 1101 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
更新2
sudo apt-get install ca-certificates-java
Reading package lists... Done
Building dependency tree
Reading state information... Done
ca-certificates-java is already the newest version (20170930ubuntu1).
ca-certificates-java set to manually installed.
The following packages were automatically installed and are no longer required:
libice-dev libsm-dev libxt-dev
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
答案 0 :(得分:8)
根本原因是openjdk-11-jdk(在Ubuntu 18.04中是默认的)和sbt包设置之间的冲突。它已经在Debian中修复,很快就会被包含在Ubuntu中。同时,最简单的解决方法是将您的java降级为版本8.使用ca-certificates-java
的其他解决方案要复杂得多。
首先删除冲突的包:
sudo apt-get remove --purge openjdk* java-common default-jdk
sudo apt-get remove --purge sbt
sudo apt-get autoremove --purge
通过以下方式检查您成功删除所有相关包裹的天气:
sudo update-alternatives --config java
系统会提示您没有可用于配置的Java ,否则此解决方法将失败。
然后重新安装所需的包:
sudo apt-get install openjdk-8-jdk sbt
测试:
sbt compile
答案 1 :(得分:2)
问题是java-certificates所以你需要运行这些命令:
$ sudo apt-get purge openjdk-8-jdk java-common
$ sudo apt-get install openjdk-8-jdk
$ sbt
答案 2 :(得分:0)
我建议您完全独立于OS软件包安装Java / Scala / SBT。对于开发人员而言apt-get
,yum
或其他任何东西安装了特定版本的Java并不重要(或无关紧要!)。
从开发人员的角度来看,在多个Java版本下测试您的应用程序甚至是有意义的。我以前见过这种情况:"它有效"在Java 1.8.x下但是"它失败了#34;在Java 1.8.y。
下因此,从开发人员的角度来看,您会对快速切换Java版本感兴趣,以便您可以快速确保它在这几个不同版本下正常工作,无论您的特定版本安装在哪个特定版本上操作系统。
如果您喜欢这个想法,这就是它的工作原理:
$HOME/tools
。我有一个脚本可以自动为您安装某个版本的JDK:https://github.com/frgomes/bash-scripts/blob/master/scripts/user-install/install-java.sh virtualenv
方式调整环境变量。它比你想象的容易,你甚至不需要virtualenv
。您所需要的只是source
一个shell脚本,它在登录时运行,定义JAVA_HOME
,指向您$HOME/tools
下的给定Java版本。这是一个例子:https://github.com/frgomes/bash-scripts/blob/master/bashrc-virtualenvs/j8s12/bin/postactivate 答案 3 :(得分:0)
这为我修复了它。
sudo update-ca-certificates -f
答案 4 :(得分:0)
就我而言,我通过删除.m2
,.ivy
和.sbt
解决了这一问题。
下次执行sbt
时,它修复了所有问题。
我相信我在使用缓存的依赖项或其他东西时会破坏sbt。