项目已springboot为主,有时候咱们须要引入的jar包并不是maven公共库中存在(这里不谈私自搭建私库),那咱们可否像普通的工程同样,导入本身手动添加的jar包文件呢?spring
答案是确定的,来,一块儿往下看,首先在resource/ 下自建 lib 目录springboot
而后,咱们在pom.xml里添加以下配置maven
<!-- 引入本地jar --> <dependency> <groupId>xxxxxx</groupId> <artifactId>xxxxx</artifactId> <version>xxxxxx</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/aspose-words-18.9-jdk16.jar</systemPath> </dependency>
这里的 ${project.basedir} 就是本工程的当前根路径, 至于 groupId artifactId version ,能够根据jar包的文件名,自行定义。spring-boot
到这里,咱们已经能够正常使用了,请使用各自的IDE试试就明白了。ui
那么,下面的问题,咱们打包出去后,会发现,发行包里,并不会存在这个自行加载的JAR包,咋办?继续往下看。spa
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 将外部的jar打包到自身jar文件里 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
只要按照上面的配置,继续修改pom.xml内容便可。code
好了,大功告成。xml
最后,欢迎转载,但请标注原著地址,谢谢。blog