您好,登錄后才能下訂單哦!
本篇內容主要講解“maven的坐標以及倉庫介紹和配置”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“maven的坐標以及倉庫介紹和配置”吧!
1.什么是maven倉庫?
1.1 倉庫和構件
倉庫指的是在某個位置統一存儲所有maven項目共享構件。
構件可以是一個插件 可以是一個jar包也可以是我們自己輸出的構建(或者說對項目打的包)
1.2 倉庫分類
1.3 倉庫中尋找構件的過程?
2.什么是maven坐標(依賴)?
2.1 坐標(依賴)定義
坐標是標識構件在倉庫中的唯一位置。
2.2 如何添加坐標(依賴)?
例如:添加一個spring-test.jar的依賴過程
1).打開maven的中央倉庫:http://search.maven.org/
2).搜索倉庫:
http://search.maven.org/#artifactdetails|org.springframework|spring-test|3.2.16.RELEASE|jar
3).配置maven pom,添加一組依賴<dependencies>,拷貝上面坐標地址:
Xml代碼
1. <dependencies> 2. <dependency> 3. <groupid>org.springframework</groupid> 4. <artifactid>spring-test</artifactid> 5. <version>3.2.16.RELEASE</version> 6. </dependency> 7. </dependencies>
mvn install :發布到本地倉庫
mvn deploy : 發布到遠程倉庫
對本地項目發布到本地倉庫:(本地倉庫地址:D:\mavenRepository3\com\sohu\train\maven-02\1.0-SNAPSHORT\maven-02-1.0-SNAPSHORT.jar)
Xml代碼
1. E:\\train\\test\\maven-02>mvn clean install 2. \[INFO\] Scanning for projects... 3. \[WARNING\] 4. \[WARNING\] Some problems were encountered while building the effective model for com.sohu.train:maven-02:jar:1.0-SNAPSHORT 5. \[WARNING\] 'dependencies.dependency.exclusions.exclusion.groupId' for junit:junit:jar is missing. @ line 38, column 16 6. \[WARNING\] 'dependencies.dependency.exclusions.exclusion.artifactId' for junit:junit:jar is missing. @ line 38, column 16 7. \[WARNING\] 8. \[WARNING\] It is highly recommended to fix these problems because they threaten the stability of your build. 9. \[WARNING\] 10. \[WARNING\] For this reason, future Maven versions might no longer support building such malformed projects. 11. \[WARNING\] 12. \[INFO\] 13. \[INFO\] ------------------------------------------------------------------------ 14. \[INFO\] Building maven-02 1.0-SNAPSHORT 15. \[INFO\] ------------------------------------------------------------------------ 16. \[INFO\] 17. \[INFO\] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-02 --- 18. \[INFO\] Deleting E:\\train\\test\\maven-02\\target 19. \[INFO\] 20. \[INFO\] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-02 --- 21. \[INFO\] Using 'UTF-8' encoding to copy filtered resources. 22. \[INFO\] skip non existing resourceDirectory E:\\train\\test\\maven-02\\src\\main\\resources 23. \[INFO\] 24. \[INFO\] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-02 --- 25. \[INFO\] Changes detected - recompiling the module! 26. \[INFO\] Compiling 1 source file to E:\\train\\test\\maven-02\\target\\classes 27. \[INFO\] 28. \[INFO\] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-02 --- 29. \[INFO\] Using 'UTF-8' encoding to copy filtered resources. 30. \[INFO\] skip non existing resourceDirectory E:\\train\\test\\maven-02\\src\\test\\resources 31. \[INFO\] 32. \[INFO\] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-02 --- 33. \[INFO\] Changes detected - recompiling the module! 34. \[INFO\] Compiling 1 source file to E:\\train\\test\\maven-02\\target\\test-classes 35. \[INFO\] 36. \[INFO\] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-02 --- 37. \[INFO\] Surefire report directory: E:\\train\\test\\maven-02\\target\\surefire-reports 38. ------------------------------------------------------- 39. T E S T S 40. ------------------------------------------------------- 41. Running com.sohu.train.AppTest 42. Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec 43. Results : 44. Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 45. \[INFO\] 46. \[INFO\] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-02 --- 47. \[INFO\] Building jar: E:\\train\\test\\maven-02\\target\\maven-02-1.0-SNAPSHORT.jar 48. \[INFO\] 49. \[INFO\] --- maven-install-plugin:2.4:install (default-install) @ maven-02 --- 50. \[INFO\] Installing E:\\train\\test\\maven-02\\target\\maven-02-1.0-SNAPSHORT.jar to D:\\mavenRepository3\\com\\sohu\\train\\maven-02\\1.0-SNAPSHORT\\mave 51. n-02-1.0-SNAPSHORT.jar 52. 提交到本地倉庫 53. \[INFO\] Installing E:\\train\\test\\maven-02\\pom.xml to D:\\mavenRepository3\\com\\sohu\\train\\maven-02\\1.0-SNAPSHORT\\maven-02-1.0-SNAPSHORT.pom 54. \[INFO\] ------------------------------------------------------------------------ 55. \[INFO\] BUILD SUCCESS 56. \[INFO\] ------------------------------------------------------------------------ 57. \[INFO\] Total time: 7.112 s 58. \[INFO\] Finished at: 2016-01-13T17:08:22+08:00 59. \[INFO\] Final Memory: 13M/179M 60. \[INFO\] ------------------------------------------------------------------------
到此,相信大家對“maven的坐標以及倉庫介紹和配置”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。