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

来源:互联网 发布:向日葵虚拟局域网软件 编辑:程序博客网 时间:2024/05/29 13:23
这个问题可能是依赖的项目打包成bundle造成,比如mina就是这样的,打包成bundle,例子:

[html] view plaincopy
  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 plaincopy
  1. <plugin>  
  2.     <groupId>org.apache.felix</groupId>  
  3.     <artifactId>maven-bundle-plugin</artifactId>  
  4.     <extensions>true</extensions>  
  5. </plugin>  

其中
[html] view plaincopy
  1. <extensions>true</extensions>  
是必须的。

---------------------------------------------------------------------------------------------------------------------
今天发现,用这个方法的log4j有问题,不妨可以试试
[html] view plaincopy
  1. <dependency>  
  2.         <groupId>log4j</groupId>  
  3.         <artifactId>log4j</artifactId>  
  4.         <version>1.2.16</version>  
  5.         <type>jar</type>  
  6.         <scope>compile</scope>  
  7.         <exclusions>  
  8.             <exclusion>  
  9.                 <groupId>com.sun.jmx</groupId>  
  10.                 <artifactId>jmxri</artifactId>  
  11.             </exclusion>  
  12.             <exclusion>  
  13.                 <groupId>com.sun.jdmk</groupId>  
  14.                 <artifactId>jmxtools</artifactId>  
  15.             </exclusion>  
  16.             <exclusion>  
  17.                 <groupId>javax.jms</groupId>  
  18.                 <artifactId>jms</artifactId>  
  19.             </exclusion>  
  20.         </exclusions>  
  21.     </dependency>  

0 0