MVN:Maven bundle error:解决Maven管理的项目下"Missing artifact xxx bundle"问题

本文详细介绍了如何解决Maven项目中使用mina依赖时出现的缺失bundle依赖导致的构建失败问题。通过添加特定的maven-bundle-plugin插件到pom.xml文件中,可以有效解决此类依赖解析错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

想仔细看看mina架构,有强迫症的我不愿意直接引用下载的包,折腾了一个晚上maven和eclipse集成,用了最新版本。感谢蜗牛的文章。

例如使用maven编译使用了mina的包的工程,出现如下提示: 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Hello 1.0
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.187s
[INFO] Finished at: Tue Nov 27 06:27:12 CST 2012
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Hello: Could not resolve dependencies for project tur:Hello:jar:1.0:  The following artifacts could not be resolved: org.apache.mina:mina-core: bundle :2.0.7, org.apache.mina:mina-integration-beans:bundle:2.0.7, org.apache.mina:mina-integration-jmx:bundle:2.0.7, org.apache.mina:mina-integration-ognl:bundle:2.0.7, org.apache.mina:mina-statemachine:bundle:2.0.7: Failure to find org.apache.mina:mina-core:bundle:2.0.7 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

这个问题可能是依赖的项目打包成bundle造成,比如mina就是这样的,打包成bundle,例子:
[html]  view plain copy
  1. <dependency>  
  2.     <groupId>org.apache.mina</groupId>  
  3.     <artifactId>mina-core</artifactId>  
  4.     <version>2.0.4</version>  
  5.     <type>bundle</type>  
  6.     <scope>compile</scope>  
  7. </dependency>  

加入上面依赖出现错误如下:
11-9-26 上午10时21分30秒: Maven Builder: AUTO_BUILD requireFullBuild
11-9-26 上午10时21分30秒: Build errors for test-http-mina; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project test-http-mina: Could not resolve dependencies for project com.tecno:test-http-mina:jar:0.0.1-SNAPSHOT: Failure to find org.apache.mina:mina-core:bundle:2.0.4 in http://uk.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of uk.maven.org has elapsed or updates are forced
11-9-26 上午10时22分11秒: Refreshing [/test-http-mina/pom.xml]
11-9-26 上午10时22分11秒: Missing artifact org.apache.mina:mina-core:bundle:2.0.4:compile
11-9-26 上午10时22分11秒: Maven Builder: AUTO_BUILD 

原因
mina打包为了bundle格式,为此,需要添加插件
在maven的pom.xml中plugins段中加入plugin即可
[html]  view plain copy
  1. <plugin>  
  2.     <groupId>org.apache.felix</groupId>  
  3.     <artifactId>maven-bundle-plugin</artifactId>  
  4.     <extensions>true</extensions>  
  5. </plugin>  
其中
[html]  view plain copy
  1. <extensions>true</extensions>  
是必须的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值