项目场景:
有些jar包在Maven Central Repository 中没有,需要引入本地jar包
问题描述
使用本地的jar要解决两个问题:
第一、引入项目中编译通过,本地开发正常启动
第二、项目打包正常
步骤:
1.新建一个与src同级的lib目录存放jar包
- pom.xml中添加本地jar包的引用
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>yaz4j</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/yaz4j-1.0.0.jar</systemPath>
</dependency>
注意: version不写的话会报错 Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: xxx
,groupId与parent内的groupId一样就行
- 导入lib下的所有jar包
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<arguments>
<argument>${project.basedir}\lib</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>