【发布时间】: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>
【问题讨论】:
-
它是否只在 IntelliJ IDEA 或命令行 Maven 中失败?
-
看起来
google-collect前一段时间已经退役,0.5似乎是一个相当老的版本。我建议更新到 guava(google-collections 的官方继任者)并使用更新的版本。 -
google-collect 已有 10 多年的历史了...如果需要类似的东西,您可以查看 vavr.io / Eclipse Collections / Guava (search.maven.org/artifact/com.google.guava/guava) ...
标签: java maven intellij-idea maven-2 maven-3