java common-lang,Maven包错误:org.apache.commons-lang不存在(Java)

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;

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

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

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

org.apache.httpcomponents

httpclient

4.0.1

commons-lang

commons-lang

2.4

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.

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

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

$ mvn dependency:copy-dependencies

copying commons-lang JAR to your target?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值