我正在使用带有嵌入式 kafka 的 spring kafka 进行 JUnit 测试,它在 windows 上的每个测试都会出错:
Error deleting C:\Users:LXX691\AppData\Local\Temp\kafka-1103610162480947200/.lock: The process cannot access the file because it is being used by another process.
我只是做了如下的基本配置
@SpringBootTest(webEnvironment = RANDOM_PORT)
@RunWith(SpringRunner.class)
public class KafkaTest {
@Autowired
EmbeddedKafkaBroker broker;
@Before
void setUp() throws Exception() {
// setup producer and consumers
}
@Test
void test() {
producer.send(new ProducerRecord<>("topic", "content"));
}
}
任何解决建议或任何解决方法表示赞赏。