eclipse Apache 公共集合的奇怪问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13457859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:26:17  来源:igfitidea点击:

Strange issue with Apache common collection

javaeclipseapache-commons

提问by Umesh Awasthi

I am not sure what might be the cause of this issue but i am facing it since morning and seems like i am doing something wrong or i have done something wrong with my Eclipse IDE

我不确定这个问题的原因是什么,但我从早上开始就面临这个问题,似乎我做错了什么,或者我的 Eclipse IDE 做错了什么

i have included Apache commom collection is my project using maven as follow

我已经包括 Apache commom 集合是我使用 maven 的项目,如下所示

<dependency>
   <groupId>commons-collections</groupId>
   <artifactId>commons-collections</artifactId>
   <version>3.2.1</version>
</dependency>

Depedency is getting included correctly, but when i am trying to use following method of collection util

依赖被正确包含,但是当我尝试使用以下收集 util 方法时

MapUtils.isEmpty(java.util.Map map) 
or
MapUtils.isNotEmpty(java.util.Map map) 

They are not being shown in the editor and only method i can see under MapUtil is

它们没有显示在编辑器中,我在 MapUtil 下可以看到的唯一方法是

invertMap(java.util.Map map) 

i check the import statement in Eclipse and its

我检查了 Eclipse 中的导入语句及其

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;

Not sure where things are going wrong as i have used above utility method number of times, do any one have any clue

不知道哪里出了问题,因为我已经多次使用上述实用程序方法,有没有人有任何线索

采纳答案by Caesar Ralf

Are you sure it's 3.2.1 you are using? Check from where the import is comming from. You maybe having some conflict, because one of your libs is importing another version of apache.commons.

您确定您使用的是 3.2.1 吗?检查导入的来源。您可能有一些冲突,因为您的一个库正在导入另一个版本的 apache.commons。

Try importing "org.apache.commons.collections.MapUtils" and see if there's still a problem.

尝试导入“org.apache.commons.collections.MapUtils”,看看是否还有问题。

回答by randominstanceOfLivingThing

Your import is correct. CollectionUtils ( http://commons.apache.org/collections/apidocs/index.html?org/apache/commons/collections/CollectionUtils.html) has methods

您的导入是正确的。CollectionUtils ( http://commons.apache.org/collections/apidocs/index.html?org/apache/commons/collections/CollectionUtils.html) 有方法

CollectionUtils.isEmpty(java.util.Map map) 
CollectionUtils.isNotEmpty(java.util.Map map) 

You are just looking int the wrong class MapUtils.

您只是在寻找错误的类 MapUtils。