i'm Shendi
記錄一下,簡單的幾步
我們將jar包複製到項目中
一般爲resources下,在哪都行,只要在項目內,比如項目根目錄
在 pom.xml 中引入
<dependency>
<groupId>隨便填</groupId>
<artifactId>隨便填</artifactId>
<version>隨便填</version>
<scope>system</scope>
<systemPath>${project.basedir}/你jar在項目中的位置</systemPath>
</dependency>
其中 systemPath是代表 jar 包位置, 裏面的 ${project.basedir} 代表項目根目錄.
例如我項目 根目錄下有lib目錄, 並且裏面有個jar爲 jdbc.jar,那麼我systemPath就爲
<systemPath>${project.basedir}/lib/jdbc.jar</systemPath>
現在已經可以讓項目直接運行了.
但是打包運行還不可以,還需要給 SpringBoot的打包插件配置 includeSystemScope 爲 true
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>