1、在resources目录下创建一个lib文件夹,把jar包放进去。
2、项目中有的时候会引入maven中央仓库中没有的依赖包,可以在pom文件中这么配置
<dependency>
<groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.29-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${pom.basedir}/src/main/resources/lib/fastdfs-client-java-1.29-SNAPSHOT.jar</systemPath>
</dependency>
3、注意打包的时候要在spring-boot-maven-plugin中加入includeSystemScope为true,这样maven在install的时候才会打包进去
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.govern.GovernApplication</mainClass> <includeSystemScope>true</includeSystemScope> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
<includeSystemScope>true</includeSystemScope>
在sprinboot项目中pom.xml文件加<includeSystemScope>true</includeSystemScope>,代表maven打包时会将外部引入的jar包(比如在根目录下或resource文件下新加外部jar包)打包到项目jar,在服务器上项目才能运行,不加此配置,本地可以运行,因为本地可以再lib下找到外部包,但是服务器上jar中是没有的。只要项目中引入外部的包,打包时就要引入此配置。