前言
spring boot项目开发过程中难免需要引入外部jar包,下面将以idea为例说明操作步骤
一、手动导入jar包,用于本地调试
将需要的jar包导入到项目中
二、maven-build引入jar包
1.项目中引入jar包
2.在maven中引入jar包
代码如下:
<dependency>
<groupId>com</groupId><!--随便填的文件夹名称-->
<artifactId>xxx</artifactId><!--jar包名字-->
<version>1.8.1</version><!--版本号-->
<scope>system</scope>
<systemPath>${project.basedir}/src/main/lib/xxx-1.8.1.jar</systemPath><!--路径-->
</dependency>
<!--注意:重点是systemPath这个路径必须得是你jar的路径。${project.basedir}只是一个系统自己的常量-->
3.项目打包设置pom文件
代码如下:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--这里写上main方法所在类的路径-->
<configuration>
<mainClass>com.xxx.xxx.xxxApplication</mainClass>
<includeSystemScope>true</includeSystemScope><!--外部进行打包-->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!---->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
总结
以上就是idea中spring boot引入外部jar包并打包jar包的所有操作,Eclipse的操作基本类似。