引入jar包
- 1.将jar包引入项目
- 在resources中创建lib文件夹,将jar包复制进去
- 2.在maven中引入jar包:
-
<dependency> <groupId>com</groupId><!--随便填的--> <artifactId>fastjson</artifactId><!--jar包名字--> <version>1.2.8</version><!--版本号--> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/fastjson-1.2.8.jar</systemPath><!--路径--> </dependency> <!--注意:重点是systemPath这个路径必须得是你jar的路径。其他的按照套路填就行,要求不是太严格。${project.basedir}只是一个系统自己的常量,不用管它-->
1<dependency>
2<groupId>com</groupId><!--随便填的-->
3<artifactId>fastjson</artifactId><!--jar包名字-->
4<version>1.2.8</version><!--版本号-->
5<scope>system</scope>
6<systemPath>${project.basedir}/src/main/resources/lib/fastjson-1.2.8.jar</systemPath><!--路径-->
7</dependency>
8<!--注意:重点是systemPath这个路径必须得是你jar的路径。其他的按照套路填就行,要求不是太严格。${project.basedir}只是一个系统自己的常量,不用管它-->
此时jar包已经可以正确引用了
springboot项目打包
- 设置maven-build
- 在pom中设置
-
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <!--这里写上main方法所在类的路径--> <configuration> <mainClass>com.test.addjar.AddjarApplication</mainClass> <includeSystemScope>true</includeSystemScope><!--外部进行打包--> </configuration> <executions> <execution> <goals> <goal>repackage</goal><!----> </goals> </execution> </executions> </plugin> </plugins> </build>
201<build>
2<plugins>
3<plugin>
4<groupId>org.springframework.boot</groupId>
5<artifactId>spring-boot-maven-plugin</artifactId>
6<!--这里写上main方法所在类的路径-->
7<configuration>
8<mainClass>com.test.addjar.AddjarApplication</mainClass>
9<includeSystemScope>true</includeSystemScope><!--外部进行打包-->
10</configuration>
11<executions>
12<execution>
13<goals>
14<goal>repackage</goal><!---->
15</goals>
16</execution>
17</executions>
18</plugin>
19</plugins>
20</build>