newConcurrentHashSet()无法从IntelliJ的com.google.guava中解析?

问题描述 投票:0回答:1

我正在Macbook上的IntelliJ(社区2019.2)中编译Java。

我的代码:

 import com.google.common.collect.Sets;

 public static void main(String[] args) {
    Sets.newConcurrentHashSet();// error ! cannot resolve the method !

}

我的pom:

 <dependencies>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>20.0</version>
    </dependency>

</dependencies>

基于

https://github.com/google/guava/blob/master/guava/src/com/google/common/collect/Sets.java

       Sets.newConcurrentHashSet();

应该可用。

但是,为什么我不能叫它?

java intellij-idea guava
1个回答
0
投票

请使用以下依赖项。

<dependencies>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>28.1-jre</version>
    </dependency>

</dependencies>

希望这会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.