天天看点

SpringBoot项目maven打包引入本地jar包

 第一步:导入本地jar包

这里有两种方式:

第一种:直接引入

<configuration>
    <compilerArguments>
        <extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
    </compilerArguments>
</configuration>
           

第二种:像导入maven包一样引入

<dependency>
    <groupId>org.wzy</groupId>
    <artifactId>SqlTemplate</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/SqlTemplate-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
           

第二步:因为jar包默认路径是: /src/main/webapp/WEB-INF/lib,我们jar包的路径是:/src/main/resources/lib

所以要对jar包路径进行修改,如果jar包在默认路径下,就不需要此步。

pom中加入此段即可。

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
        <webResources>
            <resource>
                <directory>${project.basedir}/src/main/resources/lib</directory>
                <targetPath>WEB-INF/lib/</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>
           

继续阅读