gpt4 book ai didi

scala - 规范2 "value in is not a member of String"

转载 作者:行者123 更新时间:2023-12-02 20:27:18 25 4
gpt4 key购买 nike

我无法编译简单的specs2 hello world示例:

import org.junit.runner.RunWith
import org.specs2.Specification
import org.specs2.runner.JUnitRunner

import org.specs2.mutable._

@RunWith(classOf[JUnitRunner])
class SampleTest extends Specification {

"The 'Hello world' string" should {
"contain 11 characters" in {
"Hello world" must have size(11)
}
"start with 'Hello'" in {
"Hello world" must startWith("Hello")
}
"end with 'world'" in {
"Hello world" must endWith("world")
}
}
}

出现错误:

:compileTestScala [ant:scalac] Element '/home/~~~~/workspaces/~~~~/build/resources/main' does not exist.
[ant:scalac] /home/~~~~/workspaces/~~~~/src/test/scala/com/~~~~/ingestion/SampleTest.scala:16: error: value in is not a member of String
[ant:scalac] "contain 11 characters" in {
[ant:scalac] one error found
:compileTestScala FAILED

我正在使用 Gradle(因此使用 @RunWith 注释)。使用specs2版本'org.specs2:specs2_2.10:2.4.15'

apply plugin: 'java'
apply plugin: 'scala'

repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/scalaz/releases"
}
}

configurations {
provided
compile.extendsFrom provided
}

dependencies {
provided 'org.apache.hadoop:hadoop-client:2.2.0'

compile 'org.scala-lang:scala-library:2.10.0',
'com.twitter:scalding-core_2.10:0.12.0',
'com.github.scopt:scopt_2.10:3.2.0',
'org.json4s:json4s-jackson_2.10:3.2.11',

'args4j:args4j:2.0.29',
'joda-time:joda-time:2.4',
'log4j:log4j:1.2.17',
'org.apache.commons:commons-compress:1.9',
'org.apache.commons:commons-lang3:3.3.2',
'org.codehaus.jackson:jackson-core-asl:1.9.13'


testCompile 'junit:junit:4.11',
'org.mockito:mockito-all:1.9.5',
'org.specs2:specs2_2.10:2.4.15'
}

jar {
dependsOn configurations.runtime
from {
(configurations.compile - configurations.provided).collect {
it.isDirectory() ? it : zipTree(it)
}
}
}

最佳答案

您需要为该语法扩展 org.specs2.mutable.Specification 而不是 org.specs2.Specification

关于scala - 规范2 "value in is not a member of String",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27642436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com