網站首頁 編程語言 正文
一、將jar添加到本地倉庫的做法:
以下面pom.xml依賴的jar包為例:
實際項目中pom.xml依賴寫法:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
打開你的cmd,輸入一下命令,Maven 安裝 JAR 包的命令是:
mvn install:install-file
-Dfile=jar包的位置
-DgroupId=上面的groupId
-DartifactId=上面的artifactId
-Dversion=上面的version -Dpackaging=jar
例如我的這個spring-context-support-3.1.0.RELEASE.jar 文件放在了"D:\mvn"中
則命令為:
mvn install:install-file
-Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar
-DgroupId=org.springframework
-DartifactId=spring-context-support
-Dversion=3.1.0.RELEASE
-Dpackaging=jar
注意:
- 任何路徑和名稱不要有中文和空格,以防出現莫名其妙的錯誤。
- 在cmd窗口輸入命令,所有命令不要回車換行,最好在文本中縮進為一行再復制過去運行
還可以解決本地倉庫是從別人那邊復制的,但是需要的jar包中央倉庫不存在,導致的執行package時出現以下異常
Failed to execute goal on project relayserver: Could not resolve dependencies for project com.xxx:xxx:war:1.0-SNAPSHOT: Failure to find xxx.xxx:xxx:jar:1.0 in http://maven.aliyun
.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed or updates are forced
二、不講jar包添加到本地倉庫也可在maven工程中使用外部jar包的做法:
假設將包htmlparser.jar放入了項目下SRC下的Resouce的lib目錄中 :
-> ${project}/lib/htmlparser.jar
則pom.xml文件中依賴可以如下:
<dependency>
<groupId>com.htmlparser</groupId>
<artifactId>htmlparser</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/htmlparser.jar</systemPath>
</dependency>
原文鏈接:https://blog.csdn.net/qq_41512902/article/details/125850927
相關推薦
- 2022-10-21 C++調用matlab函數的實例_C 語言
- 2022-12-23 C++類中如何使用定義的類型別名_C 語言
- 2022-09-16 nginx緩存以及清除緩存的使用_nginx
- 2022-10-22 BroadcastReceiver靜態注冊案例詳解_Android
- 2024-04-04 multipartFile轉file類型方法
- 2022-09-10 Python數據結構樹與算法分析_python
- 2022-05-11 springboot 忽略接收請求中的參數
- 2022-04-19 Django項目中動態設置靜態文件路徑的全過程_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支