項目已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