首页 > 解决方案 > 从 hello-world 创建 scala 项目时出现 InvalidPathException

问题描述

按照这个过程:https ://docs.scala-lang.org/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html

$ java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

当我使用以下命令时:

sbt new scala/hello-world.g8

我有以下错误:

$ sbt new scala/hello-world.g8 [error] java.nio.file.InvalidPathException: Trailing char < > at index 118: ModuleType Version Name
ExportedCommands
\Coursier\cache\v1 [error] 使用'last'获取完整日志. 项目加载失败:(r)etry、(q)uit、(l)ast 还是 (i)gnore?q

即使使用以下命令也会发生此错误:

$ sbt about [warn] no sbt.version set in project/build.properties, base directory: C:\Users\castelain.florianext\Documents\test\scala [error] java.nio.file.InvalidPathException: Trailing char < >在索引 118:ModuleType 版本名称
ExportedCommands
\Coursier\cache\v1 [错误] 对完整日志使用“最后一个”。项目加载失败:(r)etry、(q)uit、(l)ast 还是 (i)gnore?q

SBT 版本是:sbt script version: 1.3.8

我应该如何解决这个问题?

标签: scalasbt

解决方案


build.properties它抱怨在您的文件中找不到 sbt 版本。

尝试在您的test/scala空文件夹中移动,然后键入:sbt sbtVersion。这会将当前项目设置为您的scala文件夹,因此应该在其中创建一个build.properties设置了 sbt 版本的项目。

然后您可以再次尝试输入:sbt new scala/hello-world.g8.


推荐阅读