Maven如何引用自定義的jar包

轉載自https://blog.csdn.net/wabiaozia/article/details/52798194

以自己打的jar包myAlgorithm.jar爲例:

1.找到本地的.m2倉庫

在根目錄C:\Users\user\.m2\localRepository\  創建myAlgorithm文件夾 ---->再創建myAlgorithm文件夾----->再創建1.0文件夾

將myAlgorithm.jar放入該文件夾下

2.將myAlgorithm.jar更名爲myAlgorithm-1.0.jar,同時創建myAlgorithm-1.0.pom,將以下內容寫至新創建的pom文件中

<project> 
  <modelVersion>1.0.0</modelVersion> 
  <groupId>myAlgorithm</groupId> 
  <artifactId>myAlgorithm</artifactId> 
  <version>1.0</version> 
</project> 

3.在項目的pom.xml中引入依賴

<dependency>  
    <groupId>myAlgorithm</groupId>  
    <artifactId>myAlgorithm</artifactId>  
    <version>1.0</version>  
</dependency>

4.鼠標選中項目,右鍵點擊,選擇Maven->Update Project...

5.在項目中正常使用jar包中的類,及其方法

boolean temp = MyAlgorithm.test();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章