kafka.utils.Time 不存在
kafka.utils.Time doesn't exist
环境pom.xml
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.1.0</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
申请代码:
import kafka.utils.MockTime;
"""
Time mock = (Time) new MockTime();
kafka = TestUtils.createServer(kafkaConfig, mock);
"""
问题是:
TestUtils 的 createServer 函数需要一个 Time class 作为第二个参数,但 utils
中没有 Time class
这意味着
import kafka.utils.Time
会失败
如果我使用 org.apache.kafka.common.utils.Time,
TestUtils.createServer 抱怨
The method createServer(KafkaConfig, Time) from the type TestUtils refers to the missing type Time
一个函数怎么可能需要一个类型 class 不在其模块中的参数?
您需要使用实现了 org.apache.kafka.common.utils.Time
接口的东西。 org.apache.kafka.common.utils.SystemTime
或 org.apache.kafka.common.utils.MockTime
.
从 Scala 到 Java 的过渡使一些测试实用程序依赖项变得有些混乱。
环境pom.xml
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.1.0</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
申请代码:
import kafka.utils.MockTime;
"""
Time mock = (Time) new MockTime();
kafka = TestUtils.createServer(kafkaConfig, mock);
"""
问题是:
TestUtils 的 createServer 函数需要一个 Time class 作为第二个参数,但 utils
中没有 Time class这意味着
import kafka.utils.Time
会失败
如果我使用 org.apache.kafka.common.utils.Time,
TestUtils.createServer 抱怨
The method createServer(KafkaConfig, Time) from the type TestUtils refers to the missing type Time
一个函数怎么可能需要一个类型 class 不在其模块中的参数?
您需要使用实现了 org.apache.kafka.common.utils.Time
接口的东西。 org.apache.kafka.common.utils.SystemTime
或 org.apache.kafka.common.utils.MockTime
.
从 Scala 到 Java 的过渡使一些测试实用程序依赖项变得有些混乱。