maven项目开发过程中可能遇到jar包找不到maven依赖,这时没方法通过pom.xml直接引入。
有两种方法:
1、将本地jar包安装在本地maven仓库
2、将本地jar包放入项目目录中
-----------------------------------------------------------------------
这里记录一下第二种方法:
1、首先新建lib文件夹(在根目录或者resource目录下),将需要放到项目的jar包拷贝进来
2、然后在pom.xml文件加入如下配置,告诉maven导入本地jar.
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jasperreports-fonts-6.0.0.jar</systemPath>
</dependency>
其中除了systemPath配置告诉maven引入的本地jar包的位置之外,其他的配置都可以随便写
3、下面的一步配置也是最重要的一步,缺了这样一步就会导致虽然本地可以运行,但是只要使用maven打包就不行,因为maven没有将本地的jar包打到生成的包中。
4、在pom中给spring boot的打包插件设置一下includeSystemScope参数即可
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>