【问题标题】:Cannot resolve method 'combinations' in 'Sets'无法解析“集合”中的方法“组合”
【发布时间】:2021-10-26 22:56:12
【问题描述】:

我试图在 Intellij-idea 中使用 Maven 构建一个项目,但出现错误提示 "Cannot resolve method 'combinations' in 'Sets'

显示错误的代码在这里:

public Set<Set<String>> GetCombinationsSet(){
        System.out.println("Mapper: Calculating combinations");
        ArrayList<String> resources = new ArrayList<>(timeHarMap.keySet());
        Set<Set<String>> combinations = Sets.combinations(ImmutableSet.copyOf(resources), 2);
        //System.out.println(combinations.toArray().length);
        return combinations;
    }

我使用的导入:

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;

我在 pom.xml 中有番石榴依赖,尝试放置这个依赖但它不起作用:

<dependency>
    <groupId>com.google.common</groupId>
    <artifactId>google-collect</artifactId>
    <version>0.5</version>
</dependency>

我尝试构建时出现错误的图像:

【问题讨论】:

标签: java maven intellij-idea maven-2 maven-3


【解决方案1】:

在你的 pom.xml 中试试这个

<dependency>
    <groupId>com.google.common</groupId>
    <artifactId>google-collect</artifactId>
    <version>1.0</version>
</dependency>

【讨论】:

    猜你喜欢
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多