Maven包错误:org.apache.commons-lang不存在(Java) [英] Maven package error: org.apache.commons-lang does not exist (Java)

查看:12347
本文介绍了Maven包错误:org.apache.commons-lang不存在(Java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MyEclipse开发一个非常简单的Java Struts项目。一切正常,直到我想在 org.apache.commons.lang 中使用 StringUtils 类。在MyEclipse中,我导入了包,如

I'm using MyEclipse to develop a really simple Java Struts project. Everything was working fine until I wanted to use the StringUtils class in org.apache.commons.lang. In MyEclipse I imported the package like

import org.apache.commons.lang.StringUtils;

我将 commons-lang-2.4 的Jar文件添加到我的构建中路径。这一切都很好,花花公子,我得到了Intellisense,没有Eclipse或任何错误。现在,当我去做一个 mvn clean package 时,我得到一个错误,说明

I added the Jar file for commons-lang-2.4 to my build path. This all works fine and dandy and I get the Intellisense and no errors in Eclipse or anything. Now, when I go to do a mvn clean package, I get an error saying that


包org.apache.commons.lang不存在

The package org.apache.commons.lang does not exist

我在war / Pom.xml文件中检查了我将它声明为依赖

I checked in my war/Pom.xml file and I do have it declared as a dependency

<dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.0.1</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.4</version>
    </dependency>

</dependencies>

从我的研究中我发现Maven应该下载该软件包并将其安装到我的本地存储库(如果它不存在)。我检查了存储库,jar文件就在那里。我认为jar文件必须已损坏所以我删除了 commons-lang 文件夹以获得commons-lang的全新下载。现在这是我的想法,在我从本地存储库中删除它并运行 mvn clean package 之后,它就会出去并下载 commons-lang- 2.1 .pom和jar(即使pom.xml有2.4) BUT 仍然会出现编译失败,说包org.apache.commons.lang不存在的。

From my research I figured that Maven should download the package and install it to my local repository if it doesn't exists. I checked the repository and the jar file was in there. I figured the jar file must be corrupted so I deleted the commons-lang folder to get a fresh download of commons-lang. Now this is where it blows my mind, after I deleted it from the local repository and ran a mvn clean package, it goes out and downloads the commons-lang-2.1.pom and jar (even though the pom.xml has 2.4) BUT still gives a compilation failure saying that the package org.apache.commons.lang does not exist.

我没有使用Maven很长时间,所以我不确定如何解决这个问题。我错过了什么吗?我是否需要在其他地方的另一个pom.xml文件中添加依赖项?

I haven't been using Maven for very long so I'm not sure how to go about fixing this. Am I missing something? Do I need to add the dependency in another pom.xml file somewhere else?

推荐答案

尝试运行以下命令并检查输出:

Try running the following commands and examine the output:

$ mvn dependency:tree
$ mvn help:effective-pom

寻找 commons-lang ,也许某些事情会引起你的注意,例如排除或依赖性覆盖。另外,是:

Look for commons-lang, maybe something will draw your attention like excludes or dependency overrides. Also, is:

$ mvn dependency:copy-dependencies

commons-lang JAR复制到目标

这篇关于Maven包错误:org.apache.commons-lang不存在(Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆