maven打包不把仓库的jar打进去如何引用jar依赖
如果maven打包时没有将仓库的jar打进去,可以尝试以下方法引用jar依赖:
- 将jar文件手动复制到项目的lib目录下,然后在pom.xml文件中添加以下配置:
<dependency>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/example.jar</systemPath>
</dependency>
- 将jar文件安装到本地maven仓库中,然后在pom.xml文件中添加以下配置:
<dependency>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
</dependency>
- 如果jar文件不在maven中央仓库中,可以将jar文件安装到私有仓库中,然后在pom.xml文件中添加以下配置:
<repositories>
<repository>
<id>my-repo</id>
<url>http://example.com/maven-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
``
原文地址: https://www.cveoy.top/t/topic/fyHO 著作权归作者所有。请勿转载和采集!