MVN:Maven bundle error:解決Maven管理的項目下"Missing artifact xxx bundle"問題

想仔細看看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,例子:
  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即可
  1. <plugin>  
  2.     <groupId>org.apache.felix</groupId>  
  3.     <artifactId>maven-bundle-plugin</artifactId>  
  4.     <extensions>true</extensions>  
  5. </plugin>  
其中
  1. <extensions>true</extensions>  
是必須的。

發佈了40 篇原創文章 · 獲贊 14 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章