gpt4 book ai didi

java - 如何@SuppressWarnings : "Resource leak: ' client' is never closed"

转载 作者:行者123 更新时间:2023-12-02 02:14:46 28 4
gpt4 key购买 nike

我有声明:

MongoClient client = new MongoClient(uri);

还有警告:

[Java] Resource leak: 'client' is never closed

根据Do I need to explicitly close connection? ,我不需要关闭连接。

如何抑制此警告? @SuppressWarnings("???")

最佳答案

添加 @SuppressWarnings({ "resource"}) 应删除潜在资源泄漏的警告。添加其他列表,这是针对 Eclipse 的,但它们应该非常相似以供引用。

What is the list of valid @SuppressWarnings warning names in Java?

关于java - 如何@SuppressWarnings : "Resource leak: ' client' is never closed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49466690/

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